< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Domain.Entities.Service
Assembly: MechanicsSoftware.Domain
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Domain/Entities/Service.cs
Line coverage
90%
Covered lines: 28
Uncovered lines: 3
Coverable lines: 31
Total lines: 60
Line coverage: 90.3%
Branch coverage
77%
Covered branches: 14
Total branches: 18
Branch coverage: 77.7%
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%1010100%
Update(...)50%9875%

File(s)

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

#LineLine coverage
 1using MechanicsSoftware.Domain.Exceptions;
 2using MechanicsSoftware.Domain.ValueObjects;
 3
 4namespace MechanicsSoftware.Domain.Entities;
 5
 6public sealed class Service : Entity<Guid>
 7{
 8    public string Name { get; private set; } = null!;
 9    public string? Description { get; private set; }
 10    public Money BasePrice { get; private set; } = null!;
 11    public int EstimatedMinutes { get; private set; }
 12
 13213    private Service() { }
 14
 15    public static Service Create(
 16        Guid id,
 17        string name,
 18        string? description,
 19        Money basePrice,
 20        int estimatedMinutes = 0)
 6021    {
 6022        if (id == Guid.Empty)
 223            throw new DomainException("Id is required.");
 24
 5825        if (string.IsNullOrWhiteSpace(name))
 626            throw new DomainException("Name is required.");
 27
 5228        if (basePrice is null)
 229            throw new DomainException("Base price is required.");
 30
 5031        if (estimatedMinutes <= 0)
 632            throw new DomainException("EstimatedMinutes must be positive.");
 33
 4434        return new Service
 4435        {
 4436            Id = id,
 4437            Name = name.Trim(),
 4438            Description = description?.Trim(),
 4439            BasePrice = basePrice,
 4440            EstimatedMinutes = estimatedMinutes
 4441        };
 4442    }
 43
 44    public void Update(string name, string? description, Money basePrice, int estimatedMinutes)
 245    {
 246        if (string.IsNullOrWhiteSpace(name))
 047            throw new DomainException("Name is required.");
 48
 249        if (basePrice is null)
 050            throw new DomainException("Base price is required.");
 51
 252        if (estimatedMinutes <= 0)
 053            throw new DomainException("EstimatedMinutes must be positive.");
 54
 255        Name = name.Trim();
 256        Description = description?.Trim();
 257        BasePrice = basePrice;
 258        EstimatedMinutes = estimatedMinutes;
 259    }
 60}