Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"sdk": {
"version": "10.0.100",
"version": "10.0.101",
"rollForward": "latestFeature"
},
"msbuild-sdks": {
"MSTest.Sdk": "3.9.1"
"MSTest.Sdk": "4.0.2"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
26 changes: 10 additions & 16 deletions src/NLogTarget/packages.lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 2,
"dependencies": {
".NETFramework,Version=v4.6.2": {
".NETStandard,Version=v2.0": {
"Microsoft.ApplicationInsights": {
"type": "Direct",
"requested": "[2.23.0, )",
Expand All @@ -11,13 +11,13 @@
"System.Diagnostics.DiagnosticSource": "5.0.0"
}
},
"Microsoft.NETFramework.ReferenceAssemblies": {
"NETStandard.Library": {
"type": "Direct",
"requested": "[1.0.3, )",
"resolved": "1.0.3",
"contentHash": "vUc9Npcs14QsyOD01tnv/m8sQUnGTGOw1BCmKcv77LBJY7OxhJ+zJF7UD/sCL3lYNFuqmQEVlkfS4Quif6FyYg==",
"requested": "[2.0.3, )",
"resolved": "2.0.3",
"contentHash": "st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"dependencies": {
"Microsoft.NETFramework.ReferenceAssemblies.net462": "1.0.3"
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"NLog": {
Expand All @@ -38,8 +38,7 @@
"System.Memory": "4.6.3",
"System.Runtime.CompilerServices.Unsafe": "6.1.2",
"System.Text.Encodings.Web": "10.0.0",
"System.Threading.Tasks.Extensions": "4.6.3",
"System.ValueTuple": "4.6.1"
"System.Threading.Tasks.Extensions": "4.6.3"
}
},
"Microsoft.Bcl.AsyncInterfaces": {
Expand All @@ -50,10 +49,10 @@
"System.Threading.Tasks.Extensions": "4.6.3"
}
},
"Microsoft.NETFramework.ReferenceAssemblies.net462": {
"Microsoft.NETCore.Platforms": {
"type": "Transitive",
"resolved": "1.0.3",
"contentHash": "IzAV30z22ESCeQfxP29oVf4qEo8fBGXLXSU6oacv/9Iqe6PzgHDKCaWfwMBak7bSJQM0F5boXWoZS+kChztRIQ=="
"resolved": "1.1.0",
"contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
},
"System.Buffers": {
"type": "Transitive",
Expand Down Expand Up @@ -116,11 +115,6 @@
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.1.2"
}
},
"System.ValueTuple": {
"type": "Transitive",
"resolved": "4.6.1",
"contentHash": "+RJT4qaekpZ7DDLhf+LTjq+E48jieKiY9ulJ+BoxKmZblIJfIJT8Ufcaa/clQqnYvWs8jugfGSMu8ylS0caG0w=="
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions test/NLogTarget.Tests/NLogTargetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
catch (NLogConfigurationException ex)
{
Assert.Fail("Not expecting to get NLogConfigurationException but was thrown {0}", ex.Message);
Assert.Fail($"Not expecting to get NLogConfigurationException but was thrown {ex.Message}");
}
}

Expand All @@ -62,7 +62,7 @@
}
catch (NLogConfigurationException ex)
{
Assert.Fail("Expected NLogConfigurationException but none was thrown with message:{0}", ex.Message);
Assert.Fail($"Not expecting to get NLogConfigurationException but was thrown {ex.Message}");
}
}

Expand Down Expand Up @@ -259,19 +259,19 @@

var telemetry = this.adapterHelper.Channel.SentItems.FirstOrDefault() as TraceTelemetry;
Assert.IsNotNull(telemetry, "Didn't get the log event from the channel");

// Simple string should remain as is
Assert.AreEqual("SimpleValue", telemetry.Properties["SimpleString"]);

// Complex object should be serialized to JSON
Assert.IsTrue(telemetry.Properties.ContainsKey("ComplexObject"), "ComplexObject property not found");
var complexJson = telemetry.Properties["ComplexObject"];

// Verify it's JSON and contains expected properties
Assert.IsTrue(complexJson.Contains("\"Name\""), "JSON should contain Name property");

Check warning on line 271 in test/NLogTarget.Tests/NLogTargetTests.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Assert.Contains' instead of 'Assert.IsTrue' (https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0037)
Assert.IsTrue(complexJson.Contains("\"John Doe\""), "JSON should contain Name value");

Check warning on line 272 in test/NLogTarget.Tests/NLogTargetTests.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Assert.Contains' instead of 'Assert.IsTrue' (https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0037)
Assert.IsTrue(complexJson.Contains("\"Age\""), "JSON should contain Age property");

Check warning on line 273 in test/NLogTarget.Tests/NLogTargetTests.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Assert.Contains' instead of 'Assert.IsTrue' (https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0037)
Assert.IsTrue(complexJson.Contains("30"), "JSON should contain Age value");

Check warning on line 274 in test/NLogTarget.Tests/NLogTargetTests.cs

View workflow job for this annotation

GitHub Actions / build

Use 'Assert.Contains' instead of 'Assert.IsTrue' (https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0037)
Assert.IsTrue(complexJson.Contains("\"Address\""), "JSON should contain Address property");
Assert.IsTrue(complexJson.Contains("\"Street\""), "JSON should contain nested Street property");
Assert.IsTrue(complexJson.Contains("\"123 Main St\""), "JSON should contain nested Street value");
Expand All @@ -294,24 +294,24 @@
eventInfo.Properties["Array"] = new[] { 1, 2, 3 };
eventInfo.Properties["Dictionary"] = new Dictionary<string, object> { { "key1", "value1" }, { "key2", 123 } };
eventInfo.Properties["Null"] = null;

aiLogger.Log(eventInfo);

var telemetry = this.adapterHelper.Channel.SentItems.FirstOrDefault() as TraceTelemetry;
Assert.IsNotNull(telemetry, "Didn't get the log event from the channel");

// Simple types should be preserved as strings
Assert.AreEqual("Simple string", telemetry.Properties["String"]);
Assert.AreEqual("42", telemetry.Properties["Int"]);
Assert.AreEqual("True", telemetry.Properties["Bool"]);
Assert.IsTrue(telemetry.Properties["Decimal"].Contains("3.14"), "Decimal value should contain 3.14");

// Complex types should be serialized to JSON
Assert.IsTrue(telemetry.Properties["Array"].Contains("["), "Array should be JSON array");
Assert.IsTrue(telemetry.Properties["Array"].Contains("1"), "Array should contain values");
Assert.IsTrue(telemetry.Properties["Dictionary"].Contains("key1"), "Dictionary should be serialized");
Assert.IsTrue(telemetry.Properties["Dictionary"].Contains("value1"), "Dictionary should contain values");

// Null should be empty string
Assert.AreEqual(string.Empty, telemetry.Properties["Null"]);
}
Expand Down
Loading
Loading