SSPC-Tester/SSPCTester.Logic/Testing/ProtectTest.cs

32 lines
1.4 KiB
C#
Raw Normal View History

using SSPCTester.Logic.Models;
namespace SSPCTester.Logic.Testing;
2026-07-02 21:38:25 +08:00
/// <summary>保护功能测试:刷新固定保护测试项的实测值与测量状态。</summary>
public sealed class ProtectTest : ITestModule
{
2026-07-02 21:38:25 +08:00
public const string ModuleName = "保护功能";
public string Name => ModuleName;
public async Task RunAsync(TestContext ctx, IProgress<TestProgress> progress, CancellationToken ct)
{
2026-07-02 21:38:25 +08:00
ProtectTestPlan.EnsureRows(ctx.Project);
for (int i = 0; i < ctx.Project.ProtectResults.Count; i++)
{
ct.ThrowIfCancellationRequested();
2026-07-02 21:38:25 +08:00
var row = ctx.Project.ProtectResults[i];
bool preserveManualJudgement = row.Status is TestStatus.Pass or TestStatus.Fail;
if (!preserveManualJudgement)
row.Status = TestStatus.Running;
ProtectTestPlan.RefreshMeasuredValues(ctx.Project, overwriteExisting: false);
progress.Report(new TestProgress { ModuleName = Name, Step = i, TotalSteps = ctx.Project.ProtectResults.Count, Message = $"保护项测量:{row.ProtectType}" });
await Task.Delay(150, ct).ConfigureAwait(false);
2026-07-02 21:38:25 +08:00
if (!preserveManualJudgement && row.Status == TestStatus.Running)
row.Status = TestStatus.Untested;
2026-07-02 21:38:25 +08:00
progress.Report(new TestProgress { ModuleName = Name, Step = i + 1, TotalSteps = ctx.Project.ProtectResults.Count, StepStatus = row.Status });
}
}
}