< Summary

Information
Class: KT.Modules.Security.Core.Domain.RefreshToken
Assembly: KT.Modules.Security
File(s): G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Security\Core\Domain\RefreshToken.cs
Line coverage
100%
Covered lines: 28
Uncovered lines: 0
Coverable lines: 28
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%88100%
get_Id()100%11100%
get_Token()100%11100%
get_UserId()100%11100%
get_Expires()100%11100%
get_IsRevoked()100%11100%
get_IsExpired()100%11100%
get_IsActive()100%22100%
Revoke()100%22100%

File(s)

G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Security\Core\Domain\RefreshToken.cs

#LineLine coverage
 1namespace KT.Modules.Security.Core.Domain
 2{
 3    internal class RefreshToken
 4    {
 215        public RefreshToken(string id, string token, string userId, DateTime expires)
 216        {
 217            if (string.IsNullOrWhiteSpace(id))
 28                throw new ArgumentException("The identifier cannot be empty.", nameof(id));
 9
 1910            if (string.IsNullOrWhiteSpace(token))
 211                throw new ArgumentException("The token cannot be empty.", nameof(token));
 12
 1713            if (string.IsNullOrWhiteSpace(userId))
 214                throw new ArgumentException("The user identifier cannot be empty.", nameof(userId));
 15
 1516            if (expires <= DateTime.UtcNow)
 117                throw new ArgumentException("The expiration date must be in the future.", nameof(expires));
 18
 1419            Id = id;
 1420            Token = token;
 1421            UserId = userId;
 1422            Expires = expires;
 1423            IsRevoked = false;
 1424        }
 25
 1426        public string Id { get; private set; }
 1927        public string Token { get; private set; }
 1828        public string UserId { get; private set; }
 2629        public DateTime Expires { get; private set; }
 3930        public bool IsRevoked { get; private set; }
 31
 432        public bool IsExpired => DateTime.UtcNow >= Expires;
 433        public bool IsActive => !IsRevoked && !IsExpired;
 34
 35        public void Revoke()
 736        {
 737            if (IsRevoked)
 138                throw new InvalidOperationException("The token has already been revoked.");
 39
 640            IsRevoked = true;
 641        }
 42    }
 43}