public void CommunicationBearerTokenCredential_StaticTokenReturnsExpiredToken() { var tokenCredential = new CommunicationTokenCredential(ExpiredToken); var communicationBearerTokenCredential = new CommunicationBearerTokenCredential(tokenCredential); var accessToken = communicationBearerTokenCredential.GetToken(MockTokenRequestContext(), CancellationToken.None); Assert.AreEqual(ExpiredToken, accessToken.Token); }
public void CommunicationBearerTokenCredential_PassesCancelToken(bool refreshProactively) { var cancellationToken = new CancellationToken(); CancellationToken?actualCancellationToken = null; var tokenCredential = new CommunicationTokenCredential( refreshProactively, RefreshToken, c => new ValueTask <string>(RefreshToken(c)), ExpiredToken); var communicationBearerTokenCredential = new CommunicationBearerTokenCredential(tokenCredential); var accessToken = communicationBearerTokenCredential.GetToken(MockTokenRequestContext(), cancellationToken); Assert.AreEqual(cancellationToken.GetHashCode(), actualCancellationToken.GetHashCode()); string RefreshToken(CancellationToken token) { actualCancellationToken = token; return(SampleToken); } }