< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Persistence.EntityConfiguration.Bitcoin.WatchedTransactionEntityConfiguration
Assembly: NLightning.Infrastructure.Persistence
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Bitcoin/WatchedTransactionEntityConfiguration.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 45
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
ConfigureWatchedTransactionEntity(...)0%620%
OptimizeConfigurationForSqlServer(...)100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Bitcoin/WatchedTransactionEntityConfiguration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Bitcoin;
 5
 6using Domain.Channels.Constants;
 7using Domain.Crypto.Constants;
 8using Entities.Bitcoin;
 9using Enums;
 10using ValueConverters;
 11
 12public static class WatchedTransactionEntityConfiguration
 13{
 14    public static void ConfigureWatchedTransactionEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 15    {
 016        modelBuilder.Entity<WatchedTransactionEntity>(entity =>
 017        {
 018            // Set PrimaryKey
 019            entity.HasKey(e => new { e.TransactionId });
 020
 021            // Set required props
 022            entity.Property(e => e.TransactionId)
 023                  .HasConversion<TxIdConverter>()
 024                  .IsRequired();
 025            entity.Property(e => e.ChannelId)
 026                  .HasConversion<ChannelIdConverter>()
 027                  .IsRequired();
 028            entity.Property(e => e.RequiredDepth).IsRequired();
 029            entity.Property(e => e.CreatedAt).IsRequired();
 030
 031            // Configure optional props
 032            entity.Property(e => e.FirstSeenAtHeight).IsRequired(false);
 033            entity.Property(e => e.CompletedAt).IsRequired(false);
 034
 035            if (databaseType == DatabaseType.MicrosoftSql)
 036                OptimizeConfigurationForSqlServer(entity);
 037        });
 038    }
 39
 40    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<WatchedTransactionEntity> entity)
 41    {
 042        entity.Property(e => e.ChannelId).HasColumnType($"varbinary({ChannelConstants.ChannelIdLength})");
 043        entity.Property(e => e.TransactionId).HasColumnType($"varbinary({CryptoConstants.Sha256HashLen})");
 044    }
 45}