diff --git a/starsky/starskytest/starsky.foundation.platform/Exceptions/TelemetryServiceExceptionTest.cs b/starsky/starskytest/starsky.foundation.platform/Exceptions/TelemetryServiceExceptionTest.cs new file mode 100644 index 0000000000..044ffcd8b4 --- /dev/null +++ b/starsky/starskytest/starsky.foundation.platform/Exceptions/TelemetryServiceExceptionTest.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Runtime.Serialization; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using starsky.foundation.platform.Exceptions; + +namespace starskytest.starsky.foundation.platform.Exceptions +{ + [TestClass] + public class TelemetryServiceExceptionTest + { + [TestMethod] + [ExpectedException(typeof(TelemetryServiceException))] + public void TelemetryServiceException() + { + var info = new SerializationInfo(typeof(Exception), + new FormatterConverter()); + info.AddValue("Number", 1); + info.AddValue("SqlState", "SqlState"); + info.AddValue("Message", ""); + info.AddValue("InnerException", new Exception()); + info.AddValue("HelpURL", ""); + info.AddValue("StackTraceString", ""); + info.AddValue("RemoteStackTraceString", ""); + info.AddValue("RemoteStackIndex", 1); + info.AddValue("HResult", 1); + info.AddValue("Source", ""); + info.AddValue("WatsonBuckets", Array.Empty()); + + var ctor = + typeof(TelemetryServiceException).GetConstructors(BindingFlags.Instance | + BindingFlags.NonPublic | BindingFlags.InvokeMethod).FirstOrDefault(); + var instance = + ( TelemetryServiceException ) ctor!.Invoke(new object[] + { + info, + new StreamingContext(StreamingContextStates.All) + }); + + throw instance; + } + } +} diff --git a/starsky/starskytest/starsky.foundation.webtelemetry/Models/EmptyOperationHolderTest.cs b/starsky/starskytest/starsky.foundation.webtelemetry/Models/EmptyOperationHolderTest.cs new file mode 100644 index 0000000000..251f54d026 --- /dev/null +++ b/starsky/starskytest/starsky.foundation.webtelemetry/Models/EmptyOperationHolderTest.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using Microsoft.ApplicationInsights.DataContracts; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using starsky.foundation.webtelemetry.Models; + +namespace starskytest.starsky.foundation.webtelemetry.Models +{ + [TestClass] + public sealed class EmptyOperationHolderTest + { + [TestMethod] + public void EmptyOperationHolder_Disposed() + { + var operationHolder = new EmptyOperationHolder(); + operationHolder.Dispose(); + + var isDisposed = operationHolder.GetType().GetProperty("IsDisposed", BindingFlags.Instance | BindingFlags.NonPublic); + + var value = (bool?) isDisposed!.GetValue(operationHolder); + Assert.IsTrue(value); + } + } +}