< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Line coverage
86%
Covered lines: 20
Uncovered lines: 3
Coverable lines: 23
Total lines: 52
Line coverage: 86.9%
Branch coverage
55%
Covered branches: 10
Total branches: 18
Branch coverage: 55.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Build(...)55.55%191886.95%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder/Running/SeedScriptBuilder.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.DbSeeder;
 2
 3/// <summary>
 4/// The input of a SQL script (design tools): the migrations after <c>from</c> up to and including <c>to</c>, each bound
 5/// exactly as the runner would (<see cref="SeedStepPlanner"/>). The provider turns them into SQL.
 6/// </summary>
 7internal static class SeedScriptBuilder
 8{
 9    /// <returns>The migrations in id order; otherwise <c>TargetNotFound</c> or a binding / planning error.</returns>
 10    public static LayerResponse<IReadOnlyList<SeedScriptMigration>> Build( IModel model, SeedConfiguration configuration
 11    {
 312        if ( configuration.Migrations is not { IsSuccess: true, Result: { } migrations } )
 13        {
 014            return LayerResponse<IReadOnlyList<SeedScriptMigration>>.Failure( configuration.Migrations );
 15        }
 16
 617        foreach ( var id in new[] { fromMigrationId, toMigrationId }.OfType<string>() )
 18        {
 019            if ( migrations.All( m => m.Id != id ) ) { return SeedErrors.TargetNotFound( id ); }
 20        }
 21
 22
 323        var writer = new SeedRowWriter( configuration.Options, SeedEngine.Now( configuration ) );
 324        var result = new List<SeedScriptMigration>();
 25
 1826        foreach ( var migration in migrations.Where( m => ( fromMigrationId is null || string.CompareOrdinal( m.Id, from
 327                                                       && ( toMigrationId is null || string.CompareOrdinal( m.Id, toMigr
 28        {
 629            var tables = SeedMigrationBinder.Bind( model, configuration, migration );
 30
 631            if ( tables.IsFailure ) { return LayerResponse<IReadOnlyList<SeedScriptMigration>>.Failure( tables ); }
 32
 33
 634            var steps = SeedStepPlanner.Plan( tables.Result!, writer, migration.Id );
 35
 636            if ( steps.IsFailure ) { return LayerResponse<IReadOnlyList<SeedScriptMigration>>.Failure( steps ); }
 37
 638            result.Add( new SeedScriptMigration
 639                            {
 640                                Id                      = migration.Id,
 641                                ContextKey              = configuration.ContextKey,
 642                                Checksum                = migration.Checksum,
 643                                ProductVersion          = DbSeederDiagnostics.Version,
 644                                RequiresSchemaMigration = migration.Manifest.RequiresSchemaMigration,
 645                                Steps                   = steps.Result!
 646                            } );
 47        }
 48
 49
 350        return result;
 051    }
 52}