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

Information
Class: ZhEaIsNsAaBn.IntegrationTestingBases.TestDataBuilder<T>
Assembly: ZhEaIsNsAaBn.IntegrationTestingBases
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/TestPackages/ZhEaIsNsAaBn.IntegrationTestingBases/Utilities/TestDataBuilder.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 42
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
Build()100%11100%
BuildMany(...)100%22100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/TestPackages/ZhEaIsNsAaBn.IntegrationTestingBases/Utilities/TestDataBuilder.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.IntegrationTestingBases;
 2
 3/// <summary>
 4/// Base class for fluent test-data builders. Derive one per entity, set defaults in <see cref="CreateDefault"/>,
 5/// and add <c>With…</c> methods that change <see cref="Entity"/>.
 6/// </summary>
 7/// <typeparam name="T">The entity type being built.</typeparam>
 8public abstract class TestDataBuilder< T >
 9    where T : class
 10{
 11    /// <summary>Creates the builder and its <see cref="Entity"/> from <see cref="CreateDefault"/>.</summary>
 612    protected TestDataBuilder() => Entity = CreateDefault();
 13
 14
 15    /// <summary>The entity being configured.</summary>
 16    protected T Entity { get; set; }
 17
 18
 19    /// <summary>Creates a new entity with default values. Called by the constructor and by <see cref="BuildMany"/>.</su
 20    /// <returns>A new entity.</returns>
 21    protected abstract T CreateDefault();
 22
 23    /// <summary>Returns the configured entity.</summary>
 24    /// <returns><see cref="Entity"/>.</returns>
 325    public virtual T Build() => Entity;
 26
 27    /// <summary>
 28    /// Creates <paramref name="count"/> new entities from <see cref="CreateDefault"/>.
 29    /// <c>With…</c> changes on this builder are <b>not</b> applied to them.
 30    /// </summary>
 31    /// <param name="count">How many entities to create.</param>
 32    /// <returns>The new entities.</returns>
 33    public virtual List<T> BuildMany( int count )
 34    {
 335        var entities = new List<T>( count );
 36
 3337        for ( var i = 0; i < count; i++ ) { entities.Add( CreateDefault() ); }
 38
 39
 340        return entities;
 41    }
 42}