-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
starsky/starskytest/starsky.foundation.platform/Exceptions/TelemetryServiceExceptionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<byte>()); | ||
|
||
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; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
starsky/starskytest/starsky.foundation.webtelemetry/Models/EmptyOperationHolderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<RequestTelemetry>(); | ||
operationHolder.Dispose(); | ||
|
||
var isDisposed = operationHolder.GetType().GetProperty("IsDisposed", BindingFlags.Instance | BindingFlags.NonPublic); | ||
|
||
var value = (bool?) isDisposed!.GetValue(operationHolder); | ||
Assert.IsTrue(value); | ||
} | ||
} | ||
} |