Skip to content

Commit

Permalink
GH-37: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfroehling committed Jul 28, 2018
1 parent a429cde commit 1a8c288
Showing 1 changed file with 41 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_ArgumentException
client.Authorization = null;

Func<Task<TraktNoContentResponse>> act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

client.Authorization = new TraktAuthorization
{
Expand All @@ -218,7 +218,7 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_ArgumentException
};

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

client.Authorization = new TraktAuthorization
{
Expand All @@ -231,7 +231,7 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_ArgumentException
};

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

client.Authorization = new TraktAuthorization
{
Expand All @@ -244,7 +244,7 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_ArgumentException
};

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

client.Authorization = new TraktAuthorization
{
Expand All @@ -257,20 +257,7 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_ArgumentException
};

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = "mock access token",
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 0,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

client.Authorization = MockAuthorization;
client.ClientId = null;
Expand All @@ -287,6 +274,22 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_ArgumentException

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<ArgumentException>();

client.ClientId = TraktClientId;
client.ClientSecret = null;

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<ArgumentException>();

client.ClientSecret = string.Empty;

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<ArgumentException>();

client.ClientSecret = "client secret";

act = () => client.Authentication.RevokeAuthorizationAsync();
act.Should().Throw<ArgumentException>();
}

[Fact]
Expand Down Expand Up @@ -479,128 +482,43 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_With_Token_Argume
client.Authorization = null;

Func<Task<TraktNoContentResponse>> act = () => client.Authentication.RevokeAuthorizationAsync(null);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token");
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = null,
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token");
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = string.Empty,
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token");
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = "mock access token",
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null);
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token");
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = "mock access token",
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 0,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null);
act.Should().Throw<TraktAuthorizationException>();
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<TraktAuthorizationException>();
client.ClientId = null;

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token");
act.Should().Throw<TraktAuthorizationException>();
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN);
act.Should().Throw<ArgumentException>();

client.Authorization = MockAuthorization;
client.ClientId = string.Empty;

act = () => client.Authentication.RevokeAuthorizationAsync(null);
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN);
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty);
act.Should().Throw<ArgumentException>();
client.ClientId = "client id";

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token");
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN);
act.Should().Throw<ArgumentException>();

client.ClientId = null;
client.ClientId = TraktClientId;
client.ClientSecret = null;

act = () => client.Authentication.RevokeAuthorizationAsync(MockAuthorization.RefreshToken);
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN);
act.Should().Throw<ArgumentException>();

client.ClientId = string.Empty;
client.ClientSecret = string.Empty;

act = () => client.Authentication.RevokeAuthorizationAsync(MockAuthorization.RefreshToken);
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN);
act.Should().Throw<ArgumentException>();

client.ClientId = "client id";
client.ClientSecret = "client id";

act = () => client.Authentication.RevokeAuthorizationAsync(MockAuthorization.RefreshToken);
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN);
act.Should().Throw<ArgumentException>();
}

Expand Down Expand Up @@ -794,107 +712,6 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_With_Token_And_Cl
client.Authorization = null;

Func<Task<TraktNoContentResponse>> act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token", TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = null,
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token", TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = string.Empty,
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token", TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = "mock access token",
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 7200,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token", TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = new TraktAuthorization
{
CreatedAtTimestamp = TestUtility.CalculateTimestamp(TestConstants.CREATED_AT),
AccessToken = "mock access token",
TokenType = TraktAccessTokenType.Bearer,
ExpiresInSeconds = 0,
RefreshToken = TestConstants.MOCK_REFRESH_TOKEN,
Scope = TraktAccessScope.Public
};

act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token", TraktClientId);
act.Should().Throw<TraktAuthorizationException>();

client.Authorization = MockAuthorization;

act = () => client.Authentication.RevokeAuthorizationAsync(null, TraktClientId);
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(string.Empty, TraktClientId);
Expand All @@ -903,13 +720,13 @@ public void Test_TraktAuthenticationModule_RevokeAuthorization_With_Token_And_Cl
act = () => client.Authentication.RevokeAuthorizationAsync("mock refresh token", TraktClientId);
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(MockAuthorization.RefreshToken, null);
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN, null);
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(MockAuthorization.RefreshToken, string.Empty);
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN, string.Empty);
act.Should().Throw<ArgumentException>();

act = () => client.Authentication.RevokeAuthorizationAsync(MockAuthorization.RefreshToken, "client id");
act = () => client.Authentication.RevokeAuthorizationAsync(TestConstants.MOCK_ACCESS_TOKEN, "client id");
act.Should().Throw<ArgumentException>();
}
}
Expand Down

0 comments on commit 1a8c288

Please sign in to comment.