< Summary

Information
Class: KT.Domain.User
Assembly: KT.Modules.Security
File(s): G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Security\Core\Domain\User.cs
Line coverage
77%
Covered lines: 27
Uncovered lines: 8
Coverable lines: 35
Total lines: 49
Line coverage: 77.1%
Branch coverage
50%
Covered branches: 7
Total branches: 14
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%171475%
get_Id()100%11100%
get_Username()100%11100%
get_UsernameDisplay()100%11100%
get_RealName()100%11100%
get_Email()100%11100%
get_PasswordHash()100%11100%
get_CreatedAt()100%11100%
IsValidEmail(...)100%1162.5%

File(s)

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

#LineLine coverage
 1namespace KT.Domain
 2{
 3    internal class User
 4    {
 105        public User(string id, string username, string realName, string email, string passwordHash)
 106        {
 107            if (string.IsNullOrWhiteSpace(id))
 08                throw new ArgumentException("The user identifier cannot be empty.", nameof(id));
 9
 1010            if (string.IsNullOrWhiteSpace(username) || username.Length < 3)
 011                throw new ArgumentException("The username must be at least 3 characters long.", nameof(username));
 12
 1013            if (string.IsNullOrWhiteSpace(realName))
 014                throw new ArgumentException("The real name cannot be empty.", nameof(realName));
 15
 1016            if (string.IsNullOrWhiteSpace(email) || !IsValidEmail(email))
 017                throw new ArgumentException("The email address is invalid.", nameof(email));
 18
 1019            if (string.IsNullOrWhiteSpace(passwordHash))
 020                throw new ArgumentException("The password hash cannot be empty.", nameof(passwordHash));
 1021            Id = id;
 1022            Username = username.ToLower();
 1023            UsernameDisplay = username;
 1024            RealName = realName;
 1025            Email = email.ToLower();
 1026            PasswordHash = passwordHash;
 1027            CreatedAt = DateTime.UtcNow;
 1028        }
 2229        public string Id { get; private set; }
 1330        public string Username { get; private set; }
 1531        public string UsernameDisplay { get; private set; }
 1232        public string RealName { get; private set; }
 1333        public string Email { get; private set; }
 1334        public string PasswordHash { get; private set; }
 1135        public DateTime CreatedAt { get; private set; }
 36        private static bool IsValidEmail(string email)
 1037        {
 38            try
 1039            {
 1040                var addr = new System.Net.Mail.MailAddress(email);
 1041                return addr.Address == email;
 42            }
 043            catch
 044            {
 045                return false;
 46            }
 1047        }
 48    }
 49}