< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Persistence.EntityConfiguration.Node.PeerEntityConfiguration
Assembly: NLightning.Infrastructure.Persistence
File(s): /home/runner/work/NLightning/NLightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Node/PeerEntityConfiguration.cs
Tag: 57_24045730253
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 40
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ConfigurePeerEntity(...)0%620%
OptimizeConfigurationForSqlServer(...)100%210%

File(s)

/home/runner/work/NLightning/NLightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Node/PeerEntityConfiguration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Node;
 5
 6using Domain.Crypto.Constants;
 7using Entities.Node;
 8using Enums;
 9using ValueConverters;
 10
 11public static class PeerEntityConfiguration
 12{
 13    public static void ConfigurePeerEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 14    {
 015        modelBuilder.Entity<PeerEntity>(entity =>
 016        {
 017            // Set PrimaryKey
 018            entity.HasKey(e => e.NodeId);
 019
 020            // Set required props
 021            entity.Property(e => e.Host).IsRequired();
 022            entity.Property(e => e.Port).IsRequired();
 023            entity.Property(e => e.Type).IsRequired();
 024            entity.Property(e => e.LastSeenAt).IsRequired();
 025
 026            // Required byte[] properties
 027            entity.Property(e => e.NodeId)
 028                  .HasConversion<CompactPubKeyConverter>()
 029                  .IsRequired();
 030
 031            if (databaseType == DatabaseType.MicrosoftSql)
 032                OptimizeConfigurationForSqlServer(entity);
 033        });
 034    }
 35
 36    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<PeerEntity> entity)
 37    {
 038        entity.Property(e => e.NodeId).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 039    }
 40}