namespace MiniTestRunner;
///
/// Represents the results of a test run, including passed and total test counts.
/// Provides summary output and supports aggregation via the '+' operator.
///
/// The number of tests that passed.
/// The total number of tests executed.
public readonly record struct TestResults(int Passed, int Total)
{
///
/// Gets the number of failed tests.
///
public int Failed => this.Total - this.Passed;
///
/// Adds two instances together, combining their passed and total test counts.
///
/// The first test result.
/// The second test result.
/// A new instance representing the combined results.
public static TestResults operator +(TestResults left, TestResults right)
{
var passed = left.Passed + right.Passed;
var run = left.Total + right.Total;
return new TestResults(passed, run);
}
///
/// Prints a formatted summary of the test results to the console.
///
public void Summarize()
{
Console.WriteLine("******************************");
Console.WriteLine($"* Test passed: {this.Passed,5} / {this.Total,-5} *");
Console.WriteLine($"* Failed: {this.Failed,5} *");
Console.WriteLine("******************************");
}
}