Skip to content

TokenServiceTests

Namespace: UnitTests.Services

Unit tests for the TokenService class, verifying JWT token generation, validation, and refresh token functionality.

public class TokenServiceTests

Inheritance ObjectTokenServiceTests

Constructors

TokenServiceTests()

public TokenServiceTests()

Methods

GenerateAccessToken_ShouldLogInformation()

Generates an access token and verifies that it logs the appropriate information.

public void GenerateAccessToken_ShouldLogInformation()

GenerateAccessToken_WithEmptyClaims_ShouldReturnValidJwtToken()

Generates an access token with empty claims and verifies that it returns a valid JWT token.

public void GenerateAccessToken_WithEmptyClaims_ShouldReturnValidJwtToken()

GenerateAccessToken_WithValidClaims_ShouldReturnValidJwtToken()

Tests that GenerateAccessToken with valid claims returns a valid JWT token.

public void GenerateAccessToken_WithValidClaims_ShouldReturnValidJwtToken()

GenerateRefreshToken_ShouldLogInformation()

Generates a refresh token and verifies that it logs the appropriate information.

public void GenerateRefreshToken_ShouldLogInformation()

GenerateRefreshToken_ShouldReturnBase64String()

Generates a refresh token and verifies that it returns a valid base64 string.

public void GenerateRefreshToken_ShouldReturnBase64String()

GetPrincipalFromExpiredToken_WithEmptyToken_ShouldThrowArgumentException()

Gets the principal from an expired token with an empty string and verifies that it throws an ArgumentException.

public void GetPrincipalFromExpiredToken_WithEmptyToken_ShouldThrowArgumentException()

GetPrincipalFromExpiredToken_WithInvalidToken_ShouldThrowArgumentException()

Gets the principal from an expired token with an invalid token string and verifies that it throws an ArgumentException.

public void GetPrincipalFromExpiredToken_WithInvalidToken_ShouldThrowArgumentException()

GetPrincipalFromExpiredToken_WithNullToken_ShouldThrowArgumentException()

Gets the principal from an expired token with an empty token string and verifies that it throws an ArgumentException.

public void GetPrincipalFromExpiredToken_WithNullToken_ShouldThrowArgumentException()

GetPrincipalFromExpiredToken_WithTokenSignedWithDifferentKey_ShouldThrowSecurityTokenException()

Gets the principal from an expired token signed with a different key and verifies that it throws a SecurityTokenException.

public void GetPrincipalFromExpiredToken_WithTokenSignedWithDifferentKey_ShouldThrowSecurityTokenException()

GetPrincipalFromExpiredToken_WithValidToken_ShouldReturnClaimsPrincipal()

Gets the principal from an expired token and verifies that it returns a ClaimsPrincipal with the expected claims.

public void GetPrincipalFromExpiredToken_WithValidToken_ShouldReturnClaimsPrincipal()

Setup()

Sets up test fixtures and initializes mocks before each test execution.

public void Setup()