< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Domain.ValueObjects.Email
Assembly: MechanicsSoftware.Domain
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Domain/ValueObjects/Email.cs
Line coverage
92%
Covered lines: 12
Uncovered lines: 1
Coverable lines: 13
Total lines: 32
Line coverage: 92.3%
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%44100%
GetEqualityComponents()100%11100%
ToString()100%210%

File(s)

/home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Domain/ValueObjects/Email.cs

#LineLine coverage
 1using System.Text.RegularExpressions;
 2using MechanicsSoftware.Domain.Exceptions;
 3
 4namespace MechanicsSoftware.Domain.ValueObjects;
 5
 6public sealed partial class Email : ValueObject
 7{
 8    [GeneratedRegex(@"^[^@\s]+@[^@\s]+\.[^@\s]+$")]
 9    private static partial Regex EmailFormat();
 10
 11    public string Value { get; }
 12
 15813    public Email(string value)
 15814    {
 15815        if (string.IsNullOrWhiteSpace(value))
 416            throw new DomainException("Email cannot be empty.");
 17
 15418        var normalized = value.ToLowerInvariant();
 19
 15420        if (!EmailFormat().IsMatch(normalized))
 1221            throw new DomainException($"'{value}' is not a valid email address.");
 22
 14223        Value = normalized;
 14224    }
 25
 26    protected override IEnumerable<object?> GetEqualityComponents()
 2827    {
 2828        yield return Value;
 2429    }
 30
 031    public override string ToString() => Value;
 32}