< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Domain.Entities.User
Assembly: MechanicsSoftware.Domain
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Domain/Entities/User.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 39
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%11100%
Create(...)100%44100%

File(s)

/home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Domain/Entities/User.cs

#LineLine coverage
 1using MechanicsSoftware.Domain.Exceptions;
 2using MechanicsSoftware.Domain.ValueObjects;
 3
 4namespace MechanicsSoftware.Domain.Entities;
 5
 6public sealed class User : Entity<Guid>
 7{
 8    public string Name { get; private set; } = null!;
 9    public Email Email { get; private set; } = null!;
 10    public string PasswordHash { get; private set; } = null!;
 11    public string Role { get; private set; } = null!;
 12
 6613    private User() { }
 14
 15    public static User Create(Guid id, string name, string email, string passwordHash, string role)
 3016    {
 3017        if (string.IsNullOrWhiteSpace(name))
 418            throw new DomainException("User name is required.");
 19
 2620        if (string.IsNullOrWhiteSpace(passwordHash))
 421            throw new DomainException("Password hash is required.");
 22
 2223        return new User
 2224        {
 2225            Id = id,
 2226            Name = name.Trim(),
 2227            Email = new Email(email),
 2228            PasswordHash = passwordHash,
 2229            Role = role
 2230        };
 2231    }
 32
 33    public static class Roles
 34    {
 35        public const string Admin = "ADMIN";
 36        public const string Attendant = "ATTENDANT";
 37        public const string Mechanic = "MECHANIC";
 38    }
 39}