public void Setup() { this.tokenCache = new MockTokenCache(); this.credentialCache = new AdalCredentialCache { TokenCache = tokenCache.Object, }; }
public void RespectsTokenCachePersistenceOptions() { bool cacheDelegateCalled = false; var cachePersistenceOptions = new MockTokenCache(refreshDelegate: () => { cacheDelegateCalled = true; return(Task.FromResult <ReadOnlyMemory <byte> >(null)); }); var credential = InstrumentClient(new SharedTokenCacheCredential(new SharedTokenCacheCredentialOptions(cachePersistenceOptions))); Assert.ThrowsAsync <CredentialUnavailableException>(async() => await credential.GetTokenAsync(new TokenRequestContext(MockScopes.Default))); Assert.IsTrue(cacheDelegateCalled); }