public void GetTokenDelegatesToTheSourceCredential() { var mockCredential = new Mock <TokenCredential>(); var accessToken = new AccessToken("token", new DateTimeOffset(2015, 10, 27, 12, 0, 0, TimeSpan.Zero)); var resource = "the resource value"; var credential = new ServiceBusTokenCredential(mockCredential.Object); mockCredential .Setup(cred => cred.GetToken(It.Is <TokenRequestContext>(value => value.Scopes.FirstOrDefault() == resource), It.IsAny <CancellationToken>())) .Returns(accessToken) .Verifiable("The source credential GetToken method should have been called."); AccessToken tokenResult = credential.GetToken(new TokenRequestContext(new[] { resource }), CancellationToken.None); Assert.That(tokenResult, Is.EqualTo(accessToken), "The access token should match the return of the delegated call."); mockCredential.VerifyAll(); }