This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Andrew Omondi
committed
Nov 10, 2023
1 parent
57ff389
commit f99c5fb
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Microsoft.Kiota.Http.HttpClientLibrary.Tests/Middleware/ActivitySourceRegistryTests.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 Microsoft.Kiota.Http.HttpClientLibrary.Middleware; | ||
using Xunit; | ||
|
||
namespace Microsoft.Kiota.Http.HttpClientLibrary.Tests.Middleware.Registries | ||
{ | ||
public class ActivitySourceRegistryTests | ||
{ | ||
[Fact] | ||
public void Defensive() | ||
{ | ||
Assert.Throws<ArgumentNullException>(() => ActivitySourceRegistry.DefaultInstance.GetOrCreateActivitySource("")); | ||
Assert.Throws<ArgumentNullException>(() => ActivitySourceRegistry.DefaultInstance.GetOrCreateActivitySource(null)); | ||
} | ||
|
||
[Fact] | ||
public void CreatesNewInstanceOnFirstCallAndReturnsSameInstance() | ||
{ | ||
// Act | ||
var activitySource = ActivitySourceRegistry.DefaultInstance.GetOrCreateActivitySource("sample source"); | ||
Assert.NotNull(activitySource); | ||
|
||
var activitySource2 = ActivitySourceRegistry.DefaultInstance.GetOrCreateActivitySource("sample source"); | ||
Assert.NotNull(activitySource); | ||
|
||
// They are the same instance | ||
Assert.Equal(activitySource, activitySource2); | ||
} | ||
|
||
[Fact] | ||
public void CreatesDifferentInstances() | ||
{ | ||
// Act | ||
var activitySource = ActivitySourceRegistry.DefaultInstance.GetOrCreateActivitySource("sample source"); | ||
Assert.NotNull(activitySource); | ||
|
||
var activitySource2 = ActivitySourceRegistry.DefaultInstance.GetOrCreateActivitySource("sample source 2"); | ||
Assert.NotNull(activitySource); | ||
|
||
// They are not the same instance | ||
Assert.NotEqual(activitySource, activitySource2); | ||
} | ||
} | ||
} |