using SSPCTester.Devices.Interfaces; using SSPCTester.Logic.Models; namespace SSPCTester.Logic.Testing; /// 测试模块执行上下文。 public sealed class TestContext { public TestContext(Project project, ISspc sspc, IPowerSupply power, ILoad load, IDaq daq) { Project = project; Sspc = sspc; Power = power; Load = load; Daq = daq; } public Project Project { get; } public ISspc Sspc { get; } public IPowerSupply Power { get; } public ILoad Load { get; } public IDaq Daq { get; } } /// 测试进度报告。 public sealed class TestProgress { public string ModuleName { get; init; } = ""; public int Step { get; init; } public int TotalSteps { get; init; } public string Message { get; init; } = ""; public TestStatus? StepStatus { get; init; } public double PercentComplete => TotalSteps > 0 ? Step * 100.0 / TotalSteps : 0; } /// 所有测试模块的统一接口。 public interface ITestModule { string Name { get; } Task RunAsync(TestContext ctx, IProgress progress, CancellationToken ct); }