< Summary

Information
Class: ArturRios.Output.DataOutput<T>
Assembly: ArturRios.Output
File(s): D:\Repositories\dotnet-output\src\DataOutput.cs
Line coverage
100%
Covered lines: 25
Uncovered lines: 0
Coverable lines: 25
Total lines: 83
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 8
Fully covered methods: 3
Total methods: 8
Method coverage: 100%
Full method coverage: 37.5%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Data()100%11100%
get_New()100%11100%
AddData(...)100%11100%
WithData(...)100%11100%
WithError(...)100%11100%
WithErrors(...)100%11100%
WithMessage(...)100%11100%
WithMessages(...)100%11100%

File(s)

D:\Repositories\dotnet-output\src\DataOutput.cs

#LineLine coverage
 1namespace ArturRios.Output;
 2
 3/// <summary>
 4/// Represents a process output that carries a typed data payload.
 5/// </summary>
 6/// <typeparam name="T">Type of the data payload.</typeparam>
 7public class DataOutput<T> : ProcessOutput
 8{
 9    /// <summary>
 10    /// The payload data for this output. May be <c>null</c>.
 11    /// </summary>
 8112    public T? Data { get; protected set; }
 13
 14    /// <summary>
 15    /// Creates a new <see cref="DataOutput{T}"/> instance.
 16    /// </summary>
 717    public static new DataOutput<T> New => new();
 18
 19    /// <summary>
 20    /// Adds or replaces the data payload.
 21    /// </summary>
 22    /// <param name="data">The data to set.</param>
 23    public void AddData(T data)
 124    {
 125        Data = data;
 126    }
 27
 28    /// <summary>
 29    /// Fluent helper to set the data payload and return the same instance.
 30    /// </summary>
 31    /// <param name="data">The data to set.</param>
 32    /// <returns>The same <see cref="DataOutput{T}"/> instance for chaining.</returns>
 33    public DataOutput<T> WithData(T data)
 334    {
 335        Data = data;
 36
 337        return this;
 338    }
 39
 40    /// <summary>
 41    /// Fluent helper to add an error on the current instance.
 42    /// </summary>
 43    /// <param name="error">Error message to add.</param>
 44    public new DataOutput<T> WithError(string error)
 145    {
 146        AddError(error);
 47
 148        return this;
 149    }
 50
 51    /// <summary>
 52    /// Fluent helper to add multiple errors on the current instance.
 53    /// </summary>
 54    /// <param name="errors">Errors to add.</param>
 55    public new DataOutput<T> WithErrors(IEnumerable<string> errors)
 156    {
 157        AddErrors(errors);
 58
 159        return this;
 160    }
 61
 62    /// <summary>
 63    /// Fluent helper to add an informational message on the current instance.
 64    /// </summary>
 65    /// <param name="message">Message to add.</param>
 66    public new DataOutput<T> WithMessage(string message)
 167    {
 168        AddMessage(message);
 69
 170        return this;
 171    }
 72
 73    /// <summary>
 74    /// Fluent helper to add multiple informational messages on the current instance.
 75    /// </summary>
 76    /// <param name="messages">Messages to add.</param>
 77    public new DataOutput<T> WithMessages(IEnumerable<string> messages)
 178    {
 179        AddMessages(messages);
 80
 181        return this;
 182    }
 83}