From af0e4b1a541dcf0dc1916882eb21ad9fc1b128f8 Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Fri, 23 Mar 2018 17:05:23 -0700 Subject: [PATCH 1/4] Add a netstandard1.3 version of TraceListener --- src/TraceListener/TraceListener.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/TraceListener/TraceListener.csproj b/src/TraceListener/TraceListener.csproj index dc9e60d0..642be751 100644 --- a/src/TraceListener/TraceListener.csproj +++ b/src/TraceListener/TraceListener.csproj @@ -9,7 +9,7 @@ false false - net45 + net45;netstandard1.3 Microsoft.ApplicationInsights.TraceListener Microsoft.ApplicationInsights.TraceListener @@ -41,6 +41,10 @@ + + + + From 257db248be4a27d354f3cd9cf9a5381c85d2cab3 Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Sat, 24 Mar 2018 09:53:34 -0700 Subject: [PATCH 2/4] Add .NET Core TraceListener Tests --- Logging.sln | 11 + src/TraceListener/AssemblyInfo.cs | 1 + test/Shared/AdapterHelper.cs | 13 +- .../ApplicationInsightsTraceFilterTests.cs | 106 ++++++ .../ApplicationInsightsTraceListenerTests.cs | 332 ++++++++++++++++++ .../TraceListener.netcoreapp10.Tests.csproj | 37 ++ 6 files changed, 496 insertions(+), 4 deletions(-) create mode 100644 test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs create mode 100644 test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs create mode 100644 test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj diff --git a/Logging.sln b/Logging.sln index 54230689..b454b8a2 100644 --- a/Logging.sln +++ b/Logging.sln @@ -57,6 +57,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiagnosticSourceListener.ne EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldTest", "HelloWorldTest\HelloWorldTest.csproj", "{7AAF876A-43B5-4F47-B402-DC5C94948F3F}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TraceListener.netcoreapp10.Tests", "test\TraceListener.netcoreapp10.Tests\TraceListener.netcoreapp10.Tests.csproj", "{11E4A92F-154E-450B-8508-437C28744BC2}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution test\CommonTestShared\CommonTestShared.projitems*{3b9ab7fa-562d-4e4e-86e3-3348426bc0d9}*SharedItemsImports = 13 @@ -195,6 +197,14 @@ Global {7AAF876A-43B5-4F47-B402-DC5C94948F3F}.Release|Any CPU.Build.0 = Release|Any CPU {7AAF876A-43B5-4F47-B402-DC5C94948F3F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {7AAF876A-43B5-4F47-B402-DC5C94948F3F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Release|Any CPU.Build.0 = Release|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {11E4A92F-154E-450B-8508-437C28744BC2}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -218,6 +228,7 @@ Global {A964DE6D-9750-4013-8BE2-79C2AFC056E5} = {EE933574-C82B-4E59-A0D1-05328197B937} {625DABF6-C4AD-41A9-B2C0-04C9FEC2ADCF} = {2FCC45B3-D820-405D-87FA-467C96465BB1} {7AAF876A-43B5-4F47-B402-DC5C94948F3F} = {2FCC45B3-D820-405D-87FA-467C96465BB1} + {11E4A92F-154E-450B-8508-437C28744BC2} = {2FCC45B3-D820-405D-87FA-467C96465BB1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AC8888B1-0E98-49D7-BE15-EB97A6261C0D} diff --git a/src/TraceListener/AssemblyInfo.cs b/src/TraceListener/AssemblyInfo.cs index 351764f8..9d76ec30 100644 --- a/src/TraceListener/AssemblyInfo.cs +++ b/src/TraceListener/AssemblyInfo.cs @@ -31,6 +31,7 @@ [assembly: Guid("3aada9bf-fc15-42fd-ace5-4cb2f11c1f2a")] [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.Net45.Tests, PublicKey=" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.Tests, PublicKey=" + AssemblyInfo.PublicKey)] internal static class AssemblyInfo { diff --git a/test/Shared/AdapterHelper.cs b/test/Shared/AdapterHelper.cs index 9391df65..049307c1 100644 --- a/test/Shared/AdapterHelper.cs +++ b/test/Shared/AdapterHelper.cs @@ -11,6 +11,7 @@ namespace Microsoft.ApplicationInsights.Tracing.Tests using System.Reflection; using System.Threading; using Microsoft.ApplicationInsights.Channel; + using Microsoft.ApplicationInsights.Extensibility; using Microsoft.VisualStudio.TestTools.UnitTesting; public class AdapterHelper : IDisposable @@ -20,15 +21,13 @@ public class AdapterHelper : IDisposable #if NET45 || NET46 private static readonly string ApplicationInsightsConfigFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApplicationInsights.config"); -#else - private static readonly string ApplicationInsightsConfigFilePath = - Path.Combine(Path.GetDirectoryName(typeof(AdapterHelper).GetTypeInfo().Assembly.Location), "ApplicationInsights.config"); #endif public AdapterHelper(string instrumentationKey = "F8474271-D231-45B6-8DD4-D344C309AE69") { this.InstrumentationKey = instrumentationKey; - + +#if NET45 || NET46 string configuration = string.Format( @" @@ -37,6 +36,10 @@ public AdapterHelper(string instrumentationKey = "F8474271-D231-45B6-8DD4-D344C3 instrumentationKey); File.WriteAllText(ApplicationInsightsConfigFilePath, configuration); +#else + TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey; +#endif + this.Channel = new CustomTelemetryChannel(); } @@ -82,10 +85,12 @@ private void Dispose(bool dispossing) { this.Channel.Dispose(); +#if NET45 || NET46 if (File.Exists(ApplicationInsightsConfigFilePath)) { File.Delete(ApplicationInsightsConfigFilePath); } +#endif } } } diff --git a/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs b/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs new file mode 100644 index 00000000..1d6eaa5e --- /dev/null +++ b/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs @@ -0,0 +1,106 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. 2013 +// +// ----------------------------------------------------------------------- + +namespace Microsoft.ApplicationInsights.TraceListener.Tests +{ + using System; + using System.Diagnostics; + using Microsoft.ApplicationInsights.Extensibility; + using Microsoft.ApplicationInsights.Tracing.Tests; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Disposing the object on the TestCleanup method")] + public class ApplicationInsightsTraceFilterTests + { + private AdapterHelper adapterHelper; + + public TestContext TestContext { get; set; } + + [TestInitialize] + public void Initialize() + { + this.adapterHelper = new AdapterHelper(); + } + + [TestCleanup] + public void Cleanup() + { + this.adapterHelper.Dispose(); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void RespectFilterForWrite() + { + this.TraceFilterTestHelper( + (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => + traceListener.Write("message"), + false, + SourceLevels.Warning); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TreatWriteAsVerbose() + { + this.TraceFilterTestHelper( + (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => + traceListener.Write("message"), + true, + SourceLevels.Verbose); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void RespectFilterForWriteLine() + { + this.TraceFilterTestHelper( + (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => + traceListener.WriteLine("message"), + false, + SourceLevels.Warning); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TreatWriteLineAsVerbose() + { + this.TraceFilterTestHelper( + (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => + traceListener.WriteLine("message"), + true, + SourceLevels.Verbose); + } + + private void TraceFilterTestHelper( + Action callTraceEent, + bool shouldTrace, + SourceLevels filterLevel = SourceLevels.Warning) + { + TraceEventCache shimTraceEventCache = new TraceEventCache(); + + using (var traceListener = new ApplicationInsightsTraceListener(this.adapterHelper.InstrumentationKey)) + { + var telemetryConfiguration = new TelemetryConfiguration + { + InstrumentationKey = Guid.NewGuid().ToString(), + TelemetryChannel = this.adapterHelper.Channel + }; + + traceListener.TelemetryClient = new TelemetryClient(telemetryConfiguration); + + var traceFilter = new EventTypeFilter(filterLevel); + traceListener.Filter = traceFilter; + + callTraceEent(traceListener, shimTraceEventCache); + + Assert.AreEqual(shouldTrace, this.adapterHelper.Channel.SentItems.Length == 1); + } + } + } +} diff --git a/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs b/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs new file mode 100644 index 00000000..3a30841e --- /dev/null +++ b/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs @@ -0,0 +1,332 @@ +namespace Microsoft.ApplicationInsights.TraceListener.Tests +{ + using System; + using System.Diagnostics; + using System.Linq; + using System.Reflection; + using Microsoft.ApplicationInsights.CommonTestShared; + using Microsoft.ApplicationInsights.DataContracts; + using Microsoft.ApplicationInsights.Extensibility; + using Microsoft.ApplicationInsights.Extensibility.Implementation; + using Microsoft.ApplicationInsights.Tracing.Tests; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + [TestClass] + public sealed class ApplicationInsightsTraceListenerTests : IDisposable + { + private readonly AdapterHelper adapterHelper = new AdapterHelper(); + + public TestContext TestContext { get; set; } + + public void Dispose() + { + this.adapterHelper.Dispose(); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerInitializeDoesNotThrowWhenInstrumentationKeyIsNull() + { + var listener = new ApplicationInsightsTraceListener(null); + listener.Dispose(); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerInitializeTDoesNoThrowWhenInstrumentationKeyIsEmpty() + { + var listener = new ApplicationInsightsTraceListener(string.Empty); + listener.Dispose(); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerWriteUsedApplicationInsightsConfigInstrumentationKeyWhenUnspecifiedInstrumentationKey2() + { + // Changing the channel to Mock channel to verify + // the Telemetry event is assigned with the InstrumentationKey from configuration + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + + using (var listener = new ApplicationInsightsTraceListener(null)) + { + this.VerifyMessagesInMockChannel(listener, this.adapterHelper.InstrumentationKey); + } + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerWriteNotUsingAppliocationInsightsConfigInstrumentationKeyWhenspecifiedInstrumentationKey() + { + // Changing the channel to Mock channel to verify + // the Telemetry event is assigned with the InstrumentationKey from configuration + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + string instrumentationKey = Guid.NewGuid().ToString(); + + using (var listener = new ApplicationInsightsTraceListener(instrumentationKey)) + { + this.VerifyMessagesInMockChannel(listener, instrumentationKey); + } + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerWriteLineUseApplicationEventSourceToLogMessage() + { + // Changing the channel to Mock channel to verify + // the Telemetry event is assigned with the InstrumentationKey from configuration + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + + using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) + { + var expectedMessage = "A Message to write line"; + listener.WriteLine(expectedMessage); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First(); + Assert.AreEqual(expectedMessage, telemetry.Message); + Assert.IsFalse(telemetry.Properties.ContainsKey("EventId")); + Assert.AreEqual(SeverityLevel.Verbose, telemetry.SeverityLevel); + } + } + + [TestMethod] + [TestCategory("TraceListener")] + public void SdkVersionIsCorrect() + { + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + + using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) + { + listener.WriteLine("A Message to write line"); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First(); + + string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(typeof(ApplicationInsightsTraceListener), prefix: "sd:"); + Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion); + } + } + + [TestMethod] + [Ignore] + [TestCategory("TraceListener")] + public void TelemetryIsAcceptedByValidateEndpoint() + { + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + + using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) + { + listener.WriteLine("A Message to write line"); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First(); + + Assert.IsNull(TelemetrySender.ValidateEndpointSend(telemetry)); + } + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerTraceEventWithMessage() + { + TraceOptions options = TraceOptions.Timestamp; + var expectedTraceEventType = TraceEventType.Information; + var expectedMessage = "A simple message"; + var expectedEventId = 3; + + this.ValidateASingleMessageActionBased( + (ApplicationInsightsTraceListener listener, TraceEventCache cache) => + listener.TraceEvent(cache, this.TestContext.TestName, expectedTraceEventType, expectedEventId, expectedMessage), + this.adapterHelper.InstrumentationKey, + options); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(expectedMessage, telemetry.Message); + Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerTraceEventWithFormat() + { + TraceOptions options = TraceOptions.Timestamp; + var formatString = "{0} event"; + int arg0 = 1; + var expectedTraceEventType = TraceEventType.Information; + var expectedEventId = 3; + + this.ValidateASingleMessageActionBased( + (ApplicationInsightsTraceListener listener, TraceEventCache cache) => + listener.TraceEvent(cache, this.TestContext.TestName, expectedTraceEventType, expectedEventId, formatString, arg0), + this.adapterHelper.InstrumentationKey, + options); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(string.Format(formatString, arg0), telemetry.Message); + Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceDataStoresDataConvertedToStringInTraceMessage() + { + object expectedData = new Tuple(123, 123.456); + TraceOptions options = TraceOptions.Timestamp; + var expectedTraceEventType = TraceEventType.Information; + var expectedEventId = 3; + + this.ValidateASingleMessageActionBased( + (ApplicationInsightsTraceListener listener, TraceEventCache cache) => + listener.TraceData(cache, "hello", expectedTraceEventType, expectedEventId, expectedData), + this.adapterHelper.InstrumentationKey, + options); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual("(123, 123.456)", telemetry.Message); + Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerStoresDataItemsConvertedToStringInTraceMessage() + { + object[] expectedData = new object[] { new Tuple(123, 123.456), new Uri("https://foobar") }; + TraceOptions options = TraceOptions.Timestamp; + var expectedTraceEventType = TraceEventType.Information; + var expectedEventId = 3; + + this.ValidateASingleMessageActionBased( + (ApplicationInsightsTraceListener listener, TraceEventCache cache) => + listener.TraceData(cache, "hello", expectedTraceEventType, expectedEventId, expectedData), + this.adapterHelper.InstrumentationKey, + options); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual("(123, 123.456), https://foobar/", telemetry.Message); + Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerSendsVerboseAsVerbose() + { + this.ValidateASingleMessageActionBased( + (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Verbose, 3), + this.adapterHelper.InstrumentationKey, + TraceOptions.Timestamp); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(SeverityLevel.Verbose, telemetry.SeverityLevel); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerSendsInformationAsInformation() + { + this.ValidateASingleMessageActionBased( + (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Information, 3), + this.adapterHelper.InstrumentationKey, + TraceOptions.Timestamp); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(SeverityLevel.Information, telemetry.SeverityLevel); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerSendsWarningAsWarning() + { + this.ValidateASingleMessageActionBased( + (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Warning, 3), + this.adapterHelper.InstrumentationKey, + TraceOptions.Timestamp); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(SeverityLevel.Warning, telemetry.SeverityLevel); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerSendsErrorAsError() + { + this.ValidateASingleMessageActionBased( + (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Error, 3), + this.adapterHelper.InstrumentationKey, + TraceOptions.Timestamp); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(SeverityLevel.Error, telemetry.SeverityLevel); + } + + [TestMethod] + [TestCategory("TraceListener")] + public void TraceListenerSendsCriticalAsCritical() + { + this.ValidateASingleMessageActionBased( + (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Critical, 3), + this.adapterHelper.InstrumentationKey, + TraceOptions.Timestamp); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.AreEqual(SeverityLevel.Critical, telemetry.SeverityLevel); + } + + [TestMethod] + public void TraceEventDoesNotThrowArgumentNullExceptionWhenArgsIsNull() + { + var source = new TraceSource("Test", SourceLevels.All); + source.Listeners.Add(new ApplicationInsightsTraceListener()); + source.TraceInformation("TestMessage"); + } + + [TestMethod] + public void TraceListenerFlushesChannel() + { + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + + using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) + { + try + { + listener.Flush(); + Assert.Fail(); + } + catch (Exception ex) + { + Assert.AreEqual("Flush called", ex.Message); + } + } + } + + private void ValidateASingleMessageActionBased( + Action callTraceAction, + string instrumentationKey, + TraceOptions options) + { + TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; + + using (var listener = new ApplicationInsightsTraceListener(instrumentationKey)) + { + listener.TraceOutputOptions = options; + TraceEventCache traceEventCache = new TraceEventCache(); + var traceEventCacheTypeInfo = traceEventCache.GetType().GetTypeInfo(); + traceEventCacheTypeInfo.GetDeclaredField("_timeStamp").SetValue(traceEventCache, DateTime.Now.Ticks); + + callTraceAction(listener, traceEventCache); + + TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); + Assert.IsNotNull(telemetry, "didn't got the event trace to the inner channel"); + Assert.AreEqual(telemetry.Context.InstrumentationKey, instrumentationKey); + } + } + + private void VerifyMessagesInMockChannel( + ApplicationInsightsTraceListener aiListener, + string instrumentationKey) + { + aiListener.Write("Sample Write message"); + aiListener.WriteLine("Sample WriteLine message"); + aiListener.TraceEvent(new TraceEventCache(), "Sample TraceEvent", TraceEventType.Error, 0); + aiListener.TraceData(new TraceEventCache(), "Sample warning message GUID:{0}", TraceEventType.Information, 0, Guid.NewGuid()); + + AdapterHelper.ValidateChannel(this.adapterHelper, instrumentationKey, 4); + } + } +} diff --git a/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj b/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj new file mode 100644 index 00000000..0ba35d36 --- /dev/null +++ b/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj @@ -0,0 +1,37 @@ + + + + Microsoft.ApplicationInsights.TraceListener.Tests + Microsoft.ApplicationInsights.TraceListener.Tests + netcoreapp1.0 + false + false + + + + + + + + + All + + + + + + + + + + + + + + + + + + + + From 202700b519587c072c28179c5306864d06a055da Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Sat, 24 Mar 2018 17:45:42 -0700 Subject: [PATCH 3/4] Share sources between two flavors of TraceListener tests --- .../ApplicationInsightsTraceFilterTests.cs | 7 - .../ApplicationInsightsTraceListenerTests.cs | 11 +- .../ApplicationInsightsTraceFilterTests.cs | 106 ------ .../ApplicationInsightsTraceListenerTests.cs | 332 ------------------ .../TraceListener.netcoreapp10.Tests.csproj | 5 + 5 files changed, 15 insertions(+), 446 deletions(-) delete mode 100644 test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs delete mode 100644 test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs diff --git a/test/TraceListener.Net45.Tests/ApplicationInsightsTraceFilterTests.cs b/test/TraceListener.Net45.Tests/ApplicationInsightsTraceFilterTests.cs index 76ac94b3..1d6eaa5e 100644 --- a/test/TraceListener.Net45.Tests/ApplicationInsightsTraceFilterTests.cs +++ b/test/TraceListener.Net45.Tests/ApplicationInsightsTraceFilterTests.cs @@ -102,12 +102,5 @@ private void TraceFilterTestHelper( Assert.AreEqual(shouldTrace, this.adapterHelper.Channel.SentItems.Length == 1); } } - - private Tuple LookupTraceFiterExpections(bool? expectationOverride = null) - { - TraceEventType eventType = (TraceEventType)Enum.Parse(typeof(TraceEventType), (string)this.TestContext.DataRow["TraceEventType"]); - bool expect = bool.Parse((string)this.TestContext.DataRow["Expect"]); - return new Tuple(eventType, expectationOverride.HasValue == true ? expectationOverride.Value : expect); - } } } diff --git a/test/TraceListener.Net45.Tests/ApplicationInsightsTraceListenerTests.cs b/test/TraceListener.Net45.Tests/ApplicationInsightsTraceListenerTests.cs index b55d4040..be5975bb 100644 --- a/test/TraceListener.Net45.Tests/ApplicationInsightsTraceListenerTests.cs +++ b/test/TraceListener.Net45.Tests/ApplicationInsightsTraceListenerTests.cs @@ -3,6 +3,7 @@ using System; using System.Diagnostics; using System.Linq; + using System.Reflection; using Microsoft.ApplicationInsights.CommonTestShared; using Microsoft.ApplicationInsights.DataContracts; using Microsoft.ApplicationInsights.Extensibility; @@ -202,6 +203,7 @@ public void TraceListenerStoresDataItemsConvertedToStringInTraceMessage() Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); } +#if NET45 [TestMethod] [TestCategory("TraceListener")] public void TraceListenerSendsResumeAsVerbose() @@ -266,6 +268,7 @@ public void TraceListenerSendsTransferAsVerbose() TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); Assert.AreEqual(SeverityLevel.Verbose, telemetry.SeverityLevel); } +#endif [TestMethod] [TestCategory("TraceListener")] @@ -340,6 +343,7 @@ public void TraceEventDoesNotThrowArgumentNullExceptionWhenArgsIsNull() source.TraceInformation("TestMessage"); } +#if NET45 [TestMethod] public void TraceEventDoesNotStoreLogicalOperationStackInTelemetryPropertiesBecauseLongValuesAreRejected() { @@ -366,6 +370,7 @@ public void TraceEventDoesNotStoreCallStackInTelemetryPropertiesBecauseLongValue var telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.Single(); Assert.IsFalse(telemetry.Properties.ContainsKey("CallStack")); } +#endif [TestMethod] public void TraceListenerFlushesChannel() @@ -397,10 +402,14 @@ private void ValidateASingleMessageActionBased( { listener.TraceOutputOptions = options; TraceEventCache traceEventCache = new TraceEventCache(); +#if NET45 PrivateObject privateObject = new PrivateObject(traceEventCache); privateObject.SetField("timeStamp", DateTime.Now.Ticks); privateObject.SetField("stackTrace", "Environment.StackTrace"); - +#else + TypeInfo traceEventCacheType = traceEventCache.GetType().GetTypeInfo(); + traceEventCacheType.GetDeclaredField("_timeStamp").SetValue(traceEventCache, DateTime.Now.Ticks); +#endif callTraceAction(listener, traceEventCache); TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); diff --git a/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs b/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs deleted file mode 100644 index 1d6eaa5e..00000000 --- a/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceFilterTests.cs +++ /dev/null @@ -1,106 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) Microsoft Corporation. -// All rights reserved. 2013 -// -// ----------------------------------------------------------------------- - -namespace Microsoft.ApplicationInsights.TraceListener.Tests -{ - using System; - using System.Diagnostics; - using Microsoft.ApplicationInsights.Extensibility; - using Microsoft.ApplicationInsights.Tracing.Tests; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Disposing the object on the TestCleanup method")] - public class ApplicationInsightsTraceFilterTests - { - private AdapterHelper adapterHelper; - - public TestContext TestContext { get; set; } - - [TestInitialize] - public void Initialize() - { - this.adapterHelper = new AdapterHelper(); - } - - [TestCleanup] - public void Cleanup() - { - this.adapterHelper.Dispose(); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void RespectFilterForWrite() - { - this.TraceFilterTestHelper( - (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => - traceListener.Write("message"), - false, - SourceLevels.Warning); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TreatWriteAsVerbose() - { - this.TraceFilterTestHelper( - (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => - traceListener.Write("message"), - true, - SourceLevels.Verbose); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void RespectFilterForWriteLine() - { - this.TraceFilterTestHelper( - (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => - traceListener.WriteLine("message"), - false, - SourceLevels.Warning); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TreatWriteLineAsVerbose() - { - this.TraceFilterTestHelper( - (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) => - traceListener.WriteLine("message"), - true, - SourceLevels.Verbose); - } - - private void TraceFilterTestHelper( - Action callTraceEent, - bool shouldTrace, - SourceLevels filterLevel = SourceLevels.Warning) - { - TraceEventCache shimTraceEventCache = new TraceEventCache(); - - using (var traceListener = new ApplicationInsightsTraceListener(this.adapterHelper.InstrumentationKey)) - { - var telemetryConfiguration = new TelemetryConfiguration - { - InstrumentationKey = Guid.NewGuid().ToString(), - TelemetryChannel = this.adapterHelper.Channel - }; - - traceListener.TelemetryClient = new TelemetryClient(telemetryConfiguration); - - var traceFilter = new EventTypeFilter(filterLevel); - traceListener.Filter = traceFilter; - - callTraceEent(traceListener, shimTraceEventCache); - - Assert.AreEqual(shouldTrace, this.adapterHelper.Channel.SentItems.Length == 1); - } - } - } -} diff --git a/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs b/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs deleted file mode 100644 index 3a30841e..00000000 --- a/test/TraceListener.netcoreapp10.Tests/ApplicationInsightsTraceListenerTests.cs +++ /dev/null @@ -1,332 +0,0 @@ -namespace Microsoft.ApplicationInsights.TraceListener.Tests -{ - using System; - using System.Diagnostics; - using System.Linq; - using System.Reflection; - using Microsoft.ApplicationInsights.CommonTestShared; - using Microsoft.ApplicationInsights.DataContracts; - using Microsoft.ApplicationInsights.Extensibility; - using Microsoft.ApplicationInsights.Extensibility.Implementation; - using Microsoft.ApplicationInsights.Tracing.Tests; - using Microsoft.VisualStudio.TestTools.UnitTesting; - - [TestClass] - public sealed class ApplicationInsightsTraceListenerTests : IDisposable - { - private readonly AdapterHelper adapterHelper = new AdapterHelper(); - - public TestContext TestContext { get; set; } - - public void Dispose() - { - this.adapterHelper.Dispose(); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerInitializeDoesNotThrowWhenInstrumentationKeyIsNull() - { - var listener = new ApplicationInsightsTraceListener(null); - listener.Dispose(); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerInitializeTDoesNoThrowWhenInstrumentationKeyIsEmpty() - { - var listener = new ApplicationInsightsTraceListener(string.Empty); - listener.Dispose(); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerWriteUsedApplicationInsightsConfigInstrumentationKeyWhenUnspecifiedInstrumentationKey2() - { - // Changing the channel to Mock channel to verify - // the Telemetry event is assigned with the InstrumentationKey from configuration - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - - using (var listener = new ApplicationInsightsTraceListener(null)) - { - this.VerifyMessagesInMockChannel(listener, this.adapterHelper.InstrumentationKey); - } - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerWriteNotUsingAppliocationInsightsConfigInstrumentationKeyWhenspecifiedInstrumentationKey() - { - // Changing the channel to Mock channel to verify - // the Telemetry event is assigned with the InstrumentationKey from configuration - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - string instrumentationKey = Guid.NewGuid().ToString(); - - using (var listener = new ApplicationInsightsTraceListener(instrumentationKey)) - { - this.VerifyMessagesInMockChannel(listener, instrumentationKey); - } - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerWriteLineUseApplicationEventSourceToLogMessage() - { - // Changing the channel to Mock channel to verify - // the Telemetry event is assigned with the InstrumentationKey from configuration - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - - using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) - { - var expectedMessage = "A Message to write line"; - listener.WriteLine(expectedMessage); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First(); - Assert.AreEqual(expectedMessage, telemetry.Message); - Assert.IsFalse(telemetry.Properties.ContainsKey("EventId")); - Assert.AreEqual(SeverityLevel.Verbose, telemetry.SeverityLevel); - } - } - - [TestMethod] - [TestCategory("TraceListener")] - public void SdkVersionIsCorrect() - { - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - - using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) - { - listener.WriteLine("A Message to write line"); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First(); - - string expectedVersion = SdkVersionHelper.GetExpectedSdkVersion(typeof(ApplicationInsightsTraceListener), prefix: "sd:"); - Assert.AreEqual(expectedVersion, telemetry.Context.GetInternalContext().SdkVersion); - } - } - - [TestMethod] - [Ignore] - [TestCategory("TraceListener")] - public void TelemetryIsAcceptedByValidateEndpoint() - { - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - - using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) - { - listener.WriteLine("A Message to write line"); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.First(); - - Assert.IsNull(TelemetrySender.ValidateEndpointSend(telemetry)); - } - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerTraceEventWithMessage() - { - TraceOptions options = TraceOptions.Timestamp; - var expectedTraceEventType = TraceEventType.Information; - var expectedMessage = "A simple message"; - var expectedEventId = 3; - - this.ValidateASingleMessageActionBased( - (ApplicationInsightsTraceListener listener, TraceEventCache cache) => - listener.TraceEvent(cache, this.TestContext.TestName, expectedTraceEventType, expectedEventId, expectedMessage), - this.adapterHelper.InstrumentationKey, - options); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(expectedMessage, telemetry.Message); - Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerTraceEventWithFormat() - { - TraceOptions options = TraceOptions.Timestamp; - var formatString = "{0} event"; - int arg0 = 1; - var expectedTraceEventType = TraceEventType.Information; - var expectedEventId = 3; - - this.ValidateASingleMessageActionBased( - (ApplicationInsightsTraceListener listener, TraceEventCache cache) => - listener.TraceEvent(cache, this.TestContext.TestName, expectedTraceEventType, expectedEventId, formatString, arg0), - this.adapterHelper.InstrumentationKey, - options); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(string.Format(formatString, arg0), telemetry.Message); - Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceDataStoresDataConvertedToStringInTraceMessage() - { - object expectedData = new Tuple(123, 123.456); - TraceOptions options = TraceOptions.Timestamp; - var expectedTraceEventType = TraceEventType.Information; - var expectedEventId = 3; - - this.ValidateASingleMessageActionBased( - (ApplicationInsightsTraceListener listener, TraceEventCache cache) => - listener.TraceData(cache, "hello", expectedTraceEventType, expectedEventId, expectedData), - this.adapterHelper.InstrumentationKey, - options); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual("(123, 123.456)", telemetry.Message); - Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerStoresDataItemsConvertedToStringInTraceMessage() - { - object[] expectedData = new object[] { new Tuple(123, 123.456), new Uri("https://foobar") }; - TraceOptions options = TraceOptions.Timestamp; - var expectedTraceEventType = TraceEventType.Information; - var expectedEventId = 3; - - this.ValidateASingleMessageActionBased( - (ApplicationInsightsTraceListener listener, TraceEventCache cache) => - listener.TraceData(cache, "hello", expectedTraceEventType, expectedEventId, expectedData), - this.adapterHelper.InstrumentationKey, - options); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual("(123, 123.456), https://foobar/", telemetry.Message); - Assert.AreEqual(expectedEventId.ToString(), telemetry.Properties["EventId"]); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerSendsVerboseAsVerbose() - { - this.ValidateASingleMessageActionBased( - (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Verbose, 3), - this.adapterHelper.InstrumentationKey, - TraceOptions.Timestamp); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(SeverityLevel.Verbose, telemetry.SeverityLevel); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerSendsInformationAsInformation() - { - this.ValidateASingleMessageActionBased( - (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Information, 3), - this.adapterHelper.InstrumentationKey, - TraceOptions.Timestamp); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(SeverityLevel.Information, telemetry.SeverityLevel); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerSendsWarningAsWarning() - { - this.ValidateASingleMessageActionBased( - (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Warning, 3), - this.adapterHelper.InstrumentationKey, - TraceOptions.Timestamp); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(SeverityLevel.Warning, telemetry.SeverityLevel); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerSendsErrorAsError() - { - this.ValidateASingleMessageActionBased( - (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Error, 3), - this.adapterHelper.InstrumentationKey, - TraceOptions.Timestamp); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(SeverityLevel.Error, telemetry.SeverityLevel); - } - - [TestMethod] - [TestCategory("TraceListener")] - public void TraceListenerSendsCriticalAsCritical() - { - this.ValidateASingleMessageActionBased( - (listener, cache) => listener.TraceData(cache, "hello", TraceEventType.Critical, 3), - this.adapterHelper.InstrumentationKey, - TraceOptions.Timestamp); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.AreEqual(SeverityLevel.Critical, telemetry.SeverityLevel); - } - - [TestMethod] - public void TraceEventDoesNotThrowArgumentNullExceptionWhenArgsIsNull() - { - var source = new TraceSource("Test", SourceLevels.All); - source.Listeners.Add(new ApplicationInsightsTraceListener()); - source.TraceInformation("TestMessage"); - } - - [TestMethod] - public void TraceListenerFlushesChannel() - { - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - - using (var listener = new ApplicationInsightsTraceListener(Guid.NewGuid().ToString())) - { - try - { - listener.Flush(); - Assert.Fail(); - } - catch (Exception ex) - { - Assert.AreEqual("Flush called", ex.Message); - } - } - } - - private void ValidateASingleMessageActionBased( - Action callTraceAction, - string instrumentationKey, - TraceOptions options) - { - TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; - - using (var listener = new ApplicationInsightsTraceListener(instrumentationKey)) - { - listener.TraceOutputOptions = options; - TraceEventCache traceEventCache = new TraceEventCache(); - var traceEventCacheTypeInfo = traceEventCache.GetType().GetTypeInfo(); - traceEventCacheTypeInfo.GetDeclaredField("_timeStamp").SetValue(traceEventCache, DateTime.Now.Ticks); - - callTraceAction(listener, traceEventCache); - - TraceTelemetry telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault(); - Assert.IsNotNull(telemetry, "didn't got the event trace to the inner channel"); - Assert.AreEqual(telemetry.Context.InstrumentationKey, instrumentationKey); - } - } - - private void VerifyMessagesInMockChannel( - ApplicationInsightsTraceListener aiListener, - string instrumentationKey) - { - aiListener.Write("Sample Write message"); - aiListener.WriteLine("Sample WriteLine message"); - aiListener.TraceEvent(new TraceEventCache(), "Sample TraceEvent", TraceEventType.Error, 0); - aiListener.TraceData(new TraceEventCache(), "Sample warning message GUID:{0}", TraceEventType.Information, 0, Guid.NewGuid()); - - AdapterHelper.ValidateChannel(this.adapterHelper, instrumentationKey, 4); - } - } -} diff --git a/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj b/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj index 0ba35d36..a02db95d 100644 --- a/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj +++ b/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj @@ -8,6 +8,11 @@ false + + + + + From 3f5e4a449f4673fb3f8bc5bb152a1d8f49f13786 Mon Sep 17 00:00:00 2001 From: Paul Harrington Date: Sun, 25 Mar 2018 07:18:41 -0700 Subject: [PATCH 4/4] Rename test assembly and move source into Shared --- src/TraceListener/AssemblyInfo.cs | 2 +- .../ApplicationInsightsTraceFilterTests.cs | 0 .../ApplicationInsightsTraceListenerTests.cs | 0 .../TraceListener.Net45.Tests.csproj | 5 +++++ test/TraceListener.Net45.Tests/packages.config | 5 ----- .../TraceListener.netcoreapp10.Tests.csproj | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) rename test/{TraceListener.Net45.Tests => Shared}/ApplicationInsightsTraceFilterTests.cs (100%) rename test/{TraceListener.Net45.Tests => Shared}/ApplicationInsightsTraceListenerTests.cs (100%) delete mode 100644 test/TraceListener.Net45.Tests/packages.config diff --git a/src/TraceListener/AssemblyInfo.cs b/src/TraceListener/AssemblyInfo.cs index 9d76ec30..f8082cd3 100644 --- a/src/TraceListener/AssemblyInfo.cs +++ b/src/TraceListener/AssemblyInfo.cs @@ -31,7 +31,7 @@ [assembly: Guid("3aada9bf-fc15-42fd-ace5-4cb2f11c1f2a")] [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.Net45.Tests, PublicKey=" + AssemblyInfo.PublicKey)] -[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.Tests, PublicKey=" + AssemblyInfo.PublicKey)] +[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.NetCoreApp10.Tests, PublicKey=" + AssemblyInfo.PublicKey)] internal static class AssemblyInfo { diff --git a/test/TraceListener.Net45.Tests/ApplicationInsightsTraceFilterTests.cs b/test/Shared/ApplicationInsightsTraceFilterTests.cs similarity index 100% rename from test/TraceListener.Net45.Tests/ApplicationInsightsTraceFilterTests.cs rename to test/Shared/ApplicationInsightsTraceFilterTests.cs diff --git a/test/TraceListener.Net45.Tests/ApplicationInsightsTraceListenerTests.cs b/test/Shared/ApplicationInsightsTraceListenerTests.cs similarity index 100% rename from test/TraceListener.Net45.Tests/ApplicationInsightsTraceListenerTests.cs rename to test/Shared/ApplicationInsightsTraceListenerTests.cs diff --git a/test/TraceListener.Net45.Tests/TraceListener.Net45.Tests.csproj b/test/TraceListener.Net45.Tests/TraceListener.Net45.Tests.csproj index a3739959..a127776e 100644 --- a/test/TraceListener.Net45.Tests/TraceListener.Net45.Tests.csproj +++ b/test/TraceListener.Net45.Tests/TraceListener.Net45.Tests.csproj @@ -7,6 +7,11 @@ false + + + + + diff --git a/test/TraceListener.Net45.Tests/packages.config b/test/TraceListener.Net45.Tests/packages.config deleted file mode 100644 index 59efec9e..00000000 --- a/test/TraceListener.Net45.Tests/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj b/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj index a02db95d..24b6963d 100644 --- a/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj +++ b/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj @@ -2,15 +2,15 @@ Microsoft.ApplicationInsights.TraceListener.Tests - Microsoft.ApplicationInsights.TraceListener.Tests + Microsoft.ApplicationInsights.TraceListener.NetCoreApp10.Tests netcoreapp1.0 false false - - + +