using System; using System.Collections.Generic; using System.Linq; namespace HC_APTBS.Models { /// /// Immutable snapshot of a completed test session captured at the moment /// fires. Lives only for the /// lifetime of the current app session — there is no cross-session storage. /// /// The is a deep copy of the pump's metadata and /// list (including per-parameter results) so that /// re-running a test on the same pump does not mutate prior history entries. /// It can be handed directly to /// to reproduce the exact PDF for this run. /// public sealed class CompletedTestRun { /// Unique identifier for the run — used as the key for per-entry delete. public Guid Id { get; init; } = Guid.NewGuid(); /// Wall-clock time the TestFinished event fired. public DateTime CompletedAt { get; init; } /// Pump model string copied from the source pump at capture time. public string PumpModel { get; init; } = string.Empty; /// Pump serial number copied from the source pump at capture time. public string PumpSerial { get; init; } = string.Empty; /// True when every evaluated parameter in every enabled phase passed. public bool OverallPassed { get; init; } /// True when the run ended via abort / stop instead of normal completion. public bool Interrupted { get; init; } /// /// Deep-cloned pump containing metadata + deep-cloned /// list with results. Safe to hand directly to . /// public PumpDefinition PumpSnapshot { get; init; } = null!; /// /// Operator observations edited on the Results page. Mutable after capture, /// persisted back from the /// when the operator exports a PDF. /// public string Observations { get; set; } = string.Empty; /// /// Space-separated list of test names in the snapshot (e.g. "WL · UP · PFP"), /// shown as a secondary label in the history list. /// public string TestNames => PumpSnapshot?.Tests != null && PumpSnapshot.Tests.Count > 0 ? string.Join(" \u00B7 ", PumpSnapshot.Tests.Select(t => t.Name)) : string.Empty; } }