public async void RefreshTokenAsync_WithValidAccount_ButFailedAuth_MustResultFalse() { var identity = IdentityBuilder.Create().WithGetAccounts("Dummy Username").Build(); var token = new OneDriveToken(identity); var expected = false; var actual = await token.RefreshTokenAsync(); Assert.Equal(expected, actual); }
public void IsTokenValid_WithNullAuth_MustResultFalse() { var identity = IdentityBuilder.Create().Build(); var token = new OneDriveToken(identity); var expected = false; var actual = token.IsTokenValid(); Assert.Equal(expected, actual); }
public async void RefreshTokenAsync_WithNullAccounts_MustResultFalse() { var identity = IdentityBuilder.Create().WithGetAccounts(accounts: null).Build(); var token = new OneDriveToken(identity); var expected = false; var actual = await token.RefreshTokenAsync(); Assert.Equal(expected, actual); }
public void Constructor_WithValidParameter_ShouldBeInitializedWithEmptyToken() { var identity = IdentityBuilder.Create().Build(); var token = new OneDriveToken(identity); var expected = ""; var actual = token.GetToken(); Assert.Equal(expected, actual); }
public async void GetToken_WithInvalidToken_MustResultEmpty() { var identity = IdentityBuilder.Create().Build(); var token = new OneDriveToken(identity); var expected = false; var actual = await token.RefreshTokenAsync(); 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 CheckConnectionAsync_WithInvalidTokenThatDidntEvolve_MustResultFalse() { var identity = IdentityBuilder.Create() .Build(); var token = new OneDriveToken(identity); var expected = false; var actual = await token.CheckConnectionAsync(); Assert.Equal(expected, actual); }
public async void DisconnectAsync_WithException_MustThrowException() { var ex = new Exception("Just a test exception"); var identity = IdentityBuilder.Create().WithGetAccounts(ex).Build(); var token = new OneDriveToken(identity); var actual = await Assert.ThrowsAsync <Exception>(async() => await token.DisconnectAsync()); Assert.NotNull(actual); Assert.Equal(ex.Message, actual.Message); }
public async void DisconnectAsync_WithAccounts_MustResultWithInvalidToken() { var identity = IdentityBuilder.Create().WithGetAccounts("Dummy Username").Build(); var token = new OneDriveToken(identity); await token.DisconnectAsync(); 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 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 ConnectAsync_WithInvalidTokenThatGetsAcquired_MustResultTrue() { var identity = IdentityBuilder.Create() .WithScopes(new string[] { "A" }) .WithAcquireTokenFromIdentity("[test]", DateTimeOffset.UtcNow, new string[] { "A" }) .Build(); var token = new OneDriveToken(identity); var expected = true; var actual = await token.ConnectAsync(); Assert.Equal(expected, actual); }
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_WithValidData_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 = token.IsTokenValid(); Assert.Equal(expected, actual); }
public async void CheckConnectionAsync_WithInvalidTokenThatGetsRefreshed_MustResultTrue() { var account = IdentityBuilder.GetAccount("Dummy Username"); var identity = IdentityBuilder .Create() .WithScopes(new string[] { "A" }) .WithGetAccounts(new IAccount[] { account }) .WithAcquireTokenSilent(account, "[test]", DateTimeOffset.UtcNow, new string[] { "A" }) .Build(); var token = new OneDriveToken(identity); var expected = true; var actual = await token.CheckConnectionAsync(); Assert.Equal(expected, actual); }
public async void RefreshTokenAsync_WithValidAccount_AndSuccessAuth_MustResultTrue() { var account = IdentityBuilder.GetAccount("Dummy Username"); var identity = IdentityBuilder .Create() .WithScopes(new string[] { "Dummy Scope" }) .WithGetAccounts(new IAccount[] { account }) .WithAcquireTokenSilent(account, "Dummy AccessCode", DateTimeOffset.UtcNow, new string[] { "Dummy Scope" }) .Build(); var token = new OneDriveToken(identity); var expected = true; var actual = await token.RefreshTokenAsync(); 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); }