< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Infrastructure.Persistence.Configurations.PartConfiguration
Assembly: MechanicsSoftware.Infrastructure
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Infrastructure/Persistence/Configurations/PartConfiguration.cs
Line coverage
100%
Covered lines: 65
Uncovered lines: 0
Coverable lines: 65
Total lines: 77
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/PartConfiguration.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
 10public sealed class PartConfiguration : IEntityTypeConfiguration<Part>
 111{
 112    public void Configure(EntityTypeBuilder<Part> builder)
 213    {
 314        builder.ToTable("parts");
 115
 216        builder.HasKey(p => p.Id);
 317        builder.Property(p => p.Id).HasColumnName("id");
 118
 319        builder.Property(p => p.Code)
 320            .HasColumnName("code")
 221            .HasMaxLength(50)
 322            .IsRequired();
 123
 324        builder.Property(p => p.Name)
 325            .HasColumnName("name")
 226            .HasMaxLength(100)
 327            .IsRequired();
 128
 329        builder.Property(p => p.Description)
 230            .HasColumnName("description")
 331            .HasMaxLength(500);
 132
 333        builder.Property(p => p.UnitPrice)
 334            .HasConversion(
 335                m => m.Cents,
 336                m => new Money(m))
 237            .HasColumnName("unit_price")
 338            .IsRequired();
 139
 340        builder.Property(p => p.StockQuantity)
 241            .HasColumnName("stock_quantity")
 342            .IsRequired();
 143
 344        builder.Property(p => p.ReservedQuantity)
 245            .HasColumnName("reserved_quantity")
 346            .IsRequired();
 47
 348        builder.Ignore(p => p.AvailableQuantity);
 149
 350        builder.HasIndex(p => p.Code)
 251            .IsUnique()
 352            .HasDatabaseName("ix_parts_code");
 153
 354        builder.Navigation(p => p.Movements)
 355            .HasField("_movements")
 356            .UsePropertyAccessMode(PropertyAccessMode.Field);
 157
 358        builder.OwnsMany(p => p.Movements, sm =>
 359        {
 360            sm.ToTable("stock_movements");
 361            sm.HasKey(s => s.Id);
 362            sm.Property(s => s.Id)
 363                .HasColumnName("id")
 364                .ValueGeneratedNever();
 365            sm.WithOwner().HasForeignKey(s => s.PartId);
 366            sm.Property(s => s.PartId).HasColumnName("part_id");
 367            sm.HasIndex(s => s.PartId).HasDatabaseName("ix_stock_movements_part_id");
 368            sm.Property(s => s.Type)
 269                .HasColumnName("type")
 270                .HasConversion<string>()
 271                .IsRequired();
 272            sm.Property(s => s.Quantity).HasColumnName("quantity").IsRequired();
 273            sm.Property(s => s.Reference).HasColumnName("reference");
 274            sm.Property(s => s.CreatedAt).HasColumnName("created_at").IsRequired();
 275        });
 276    }
 77}