< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Infrastructure.Persistence.Configurations.CustomerConfiguration
Assembly: MechanicsSoftware.Infrastructure
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Infrastructure/Persistence/Configurations/CustomerConfiguration.cs
Line coverage
100%
Covered lines: 42
Uncovered lines: 0
Coverable lines: 42
Total lines: 54
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Configure(...)100%11100%
Configure(...)100%11100%

File(s)

/home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Infrastructure/Persistence/Configurations/CustomerConfiguration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3using MechanicsSoftware.Domain.Entities;
 4using MechanicsSoftware.Domain.ValueObjects;
 5using MechanicsSoftware.Domain.Enums;
 6using MechanicsSoftware.Domain.Exceptions;
 7
 8namespace MechanicsSoftware.Infrastructure.Persistence.Configurations;
 9
 110public sealed class CustomerConfiguration : IEntityTypeConfiguration<Customer>
 111{
 12    public void Configure(EntityTypeBuilder<Customer> builder)
 313    {
 314        builder.ToTable("customers");
 15
 316        builder.HasKey(c => c.Id);
 317        builder.Property(c => c.Id).HasColumnName("id");
 118
 319        builder.Property(c => c.Name)
 220            .HasColumnName("name")
 321            .HasMaxLength(100)
 322            .IsRequired();
 123
 324        builder.Property(c => c.Phone)
 225            .HasColumnName("phone")
 226            .HasMaxLength(20)
 327            .IsRequired();
 128
 129        // TaxId — PersonType is inferred from digit count (11=CPF/INDIVIDUAL, 14=CNPJ/COMPANY)
 330        builder.Property(c => c.Document)
 331            .HasConversion(
 332                v => v.Value,
 333                v => new TaxId(v, v.Length == 11 ? PersonType.INDIVIDUAL : PersonType.COMPANY))
 234            .HasColumnName("document")
 335            .HasMaxLength(14)
 336            .IsRequired();
 137
 338        builder.Property(c => c.Email)
 339            .HasConversion(
 340                v => v.Value,
 341                v => new Email(v))
 242            .HasColumnName("email")
 343            .HasMaxLength(200)
 344            .IsRequired();
 145
 246        builder.HasIndex(c => c.Document)
 347            .IsUnique()
 348            .HasDatabaseName("ix_customers_document");
 149
 350        builder.HasIndex(c => c.Email)
 251            .IsUnique()
 252            .HasDatabaseName("ix_customers_email");
 253    }
 54}