@@ -33,42 +33,40 @@ public void InMemoryCacheExtensionsTests()
3333 public async Task CacheExtensions_CcaAlreadyExists_TestsAsync ( )
3434 {
3535 AuthenticationResult result ;
36- TestTelemetryClient testTelemetryClient = new TestTelemetryClient ( TestConstants . ClientId ) ;
3736 // new InMemory serializer and new cca
38- result = await CreateAppAndGetTokenAsync ( CacheType . InMemory , testTelemetryClient ) . ConfigureAwait ( false ) ;
37+ result = await CreateAppAndGetTokenAsync ( CacheType . InMemory ) . ConfigureAwait ( false ) ;
3938 Assert . Equal ( TokenSource . IdentityProvider , result . AuthenticationResultMetadata . TokenSource ) ;
40- AssertCacheTelemetry ( testTelemetryClient , CacheLevel . None ) ;
39+ AssertCacheTelemetry ( result , CacheLevel . None ) ;
4140
42- result = await CreateAppAndGetTokenAsync ( CacheType . InMemory , testTelemetryClient , addTokenMock : false ) . ConfigureAwait ( false ) ;
41+ result = await CreateAppAndGetTokenAsync ( CacheType . InMemory , addTokenMock : false ) . ConfigureAwait ( false ) ;
4342 Assert . Equal ( TokenSource . Cache , result . AuthenticationResultMetadata . TokenSource ) ;
44- AssertCacheTelemetry ( testTelemetryClient , CacheLevel . L1Cache ) ;
43+ AssertCacheTelemetry ( result , CacheLevel . L1Cache ) ;
4544
4645 //Resetting token caches due to potential collision with other tests
4746 TokenCacheExtensions . s_serviceProviderFromAction . Clear ( ) ;
4847
4948 // new DistributedInMemory and same cca
50- result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , testTelemetryClient ) . ConfigureAwait ( false ) ;
49+ result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory ) . ConfigureAwait ( false ) ;
5150 Assert . Equal ( TokenSource . IdentityProvider , result . AuthenticationResultMetadata . TokenSource ) ;
52- AssertCacheTelemetry ( testTelemetryClient , CacheLevel . None ) ;
51+ AssertCacheTelemetry ( result , CacheLevel . None ) ;
5352
54- result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , testTelemetryClient , addTokenMock : false ) . ConfigureAwait ( false ) ;
53+ result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , addTokenMock : false ) . ConfigureAwait ( false ) ;
5554 Assert . Equal ( TokenSource . Cache , result . AuthenticationResultMetadata . TokenSource ) ;
56- AssertCacheTelemetry ( testTelemetryClient , CacheLevel . L1Cache ) ;
55+ AssertCacheTelemetry ( result , CacheLevel . L1Cache ) ;
5756 }
5857
5958 [ Fact ]
6059 public async Task CacheExtensions_CcaAlreadyExistsL2_TestsAsync ( )
6160 {
6261 AuthenticationResult result ;
63- TestTelemetryClient testTelemetryClient = new TestTelemetryClient ( TestConstants . ClientId ) ;
6462 // new DistributedInMemory serializer with L1 cache disabled
65- result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , testTelemetryClient , disableL1Cache : true ) . ConfigureAwait ( false ) ;
63+ result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , disableL1Cache : true ) . ConfigureAwait ( false ) ;
6664 Assert . Equal ( TokenSource . IdentityProvider , result . AuthenticationResultMetadata . TokenSource ) ;
67- AssertCacheTelemetry ( testTelemetryClient , CacheLevel . None ) ;
65+ AssertCacheTelemetry ( result , CacheLevel . None ) ;
6866
69- result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , testTelemetryClient , addTokenMock : false , disableL1Cache : true ) . ConfigureAwait ( false ) ;
67+ result = await CreateAppAndGetTokenAsync ( CacheType . DistributedInMemory , addTokenMock : false , disableL1Cache : true ) . ConfigureAwait ( false ) ;
7068 Assert . Equal ( TokenSource . Cache , result . AuthenticationResultMetadata . TokenSource ) ;
71- AssertCacheTelemetry ( testTelemetryClient , CacheLevel . L2Cache ) ;
69+ AssertCacheTelemetry ( result , CacheLevel . L2Cache ) ;
7270 }
7371
7472 [ Fact ]
@@ -200,7 +198,6 @@ private enum CacheType
200198
201199 private static async Task < AuthenticationResult > CreateAppAndGetTokenAsync (
202200 CacheType cacheType ,
203- ITelemetryClient telemetryClient ,
204201 bool addTokenMock = true ,
205202 bool disableL1Cache = false )
206203 {
@@ -221,7 +218,6 @@ private static async Task<AuthenticationResult> CreateAppAndGetTokenAsync(
221218 . WithAuthority ( TestConstants . AuthorityCommonTenant )
222219 . WithHttpClientFactory ( mockHttp )
223220 . WithClientSecret ( TestConstants . ClientSecret )
224- . WithTelemetryClient ( telemetryClient )
225221 . Build ( ) ;
226222
227223 switch ( cacheType )
@@ -255,10 +251,9 @@ private static async Task<AuthenticationResult> CreateAppAndGetTokenAsync(
255251 return result ;
256252 }
257253
258- private void AssertCacheTelemetry ( TestTelemetryClient testTelemetryClient , CacheLevel cacheLevel )
254+ private void AssertCacheTelemetry ( AuthenticationResult result , CacheLevel expectedCacheLevel )
259255 {
260- TelemetryEventDetails eventDetails = testTelemetryClient . TestTelemetryEventDetails ;
261- Assert . Equal ( Convert . ToInt64 ( cacheLevel , new CultureInfo ( "en-US" ) ) , eventDetails . Properties [ "CacheLevel" ] ) ;
256+ Assert . Equal ( result . AuthenticationResultMetadata . CacheLevel , expectedCacheLevel ) ;
262257 }
263258
264259 private IConfidentialClientApplication CreateCca ( ) =>
0 commit comments