public async void IsScopeValid_WithNullAuth_MustResultFalse() { var identity = IdentityBuilder.Create().Build(); var token = new OneDriveToken(identity); await token.AcquireTokenAsync(); var expected = false; var actual = token.IsScopeValid(); Assert.Equal(expected, actual); }
public async void AcquireTokenAsync_WithException_MustResultFalse() { var ex = new Exception("Just a test exception"); var identity = IdentityBuilder.Create().WithAcquireTokenFromIdentity(ex).Build(); var token = new OneDriveToken(identity); var expected = false; var actual = await token.AcquireTokenAsync(); Assert.Equal(expected, actual); }
public async void IsScopeValid_WithSpecifiedParameters_MustResultSpecifiedValue(string[] identityScopes, string[] authScopes, bool expectedValue) { var identity = IdentityBuilder.Create() .WithScopes(identityScopes) .WithAcquireTokenFromIdentity("[test]", DateTimeOffset.UtcNow, authScopes) .Build(); var token = new OneDriveToken(identity); await token.AcquireTokenAsync(); var actualValue = token.IsScopeValid(); Assert.Equal(expectedValue, actualValue); }
public async void IsTokenValid_WithExpiredDate_MustResultFalse(double expiresSeconds) { var identity = IdentityBuilder.Create() .WithAcquireTokenFromIdentity("[test]", DateTimeOffset.UtcNow.AddSeconds(expiresSeconds), null) .Build(); var token = new OneDriveToken(identity); await token.AcquireTokenAsync(); var expected = false; var actual = token.IsTokenValid(); Assert.Equal(expected, actual); }
public async void IsTokenValid_WithEmptyAccessToken_MustResultFalse() { var identity = IdentityBuilder.Create() .WithAcquireTokenFromIdentity("", DateTimeOffset.UtcNow, null) .Build(); var token = new OneDriveToken(identity); await token.AcquireTokenAsync(); var expected = false; var actual = token.IsTokenValid(); Assert.Equal(expected, actual); }
public async void CheckConnectionAsync_WithValidToken_MustResultTrue() { var identity = IdentityBuilder.Create() .WithScopes(new string[] { "A" }) .WithAcquireTokenFromIdentity("[test]", DateTimeOffset.UtcNow, new string[] { "A" }) .Build(); var token = new OneDriveToken(identity); await token.AcquireTokenAsync(); var expected = true; var actual = await token.CheckConnectionAsync(); Assert.Equal(expected, actual); }
public async void GetToken_WithValidToken_MustResultItsValue() { var dummyToken = "My Dummy Token"; var scopes = new string[] { "A" }; var identity = IdentityBuilder .Create() .WithScopes(scopes) .WithAcquireTokenFromIdentity(dummyToken, DateTimeOffset.UtcNow, scopes) .Build(); var token = new OneDriveToken(identity); await token.AcquireTokenAsync(); var actual = token.GetToken(); Assert.Equal(dummyToken, actual); }