Files
XplorePlane/XplorePlane.Tests/ViewModels/CncNodeViewModelTests.cs
T
2026-04-27 16:18:47 +08:00

64 lines
2.4 KiB
C#

// Feature: cnc-run-execution, Property 11: 节点执行状态转换正确性
// Validates: Requirements 6.1, 6.2
using System;
using FsCheck;
using FsCheck.Fluent;
using FsCheck.Xunit;
using XplorePlane.Models;
using XplorePlane.ViewModels.Cnc;
namespace XplorePlane.Tests.ViewModels
{
public class CncNodeViewModelTests
{
// ── Property 11: 节点执行状态转换正确性 ──────────────────────────────
// Feature: cnc-run-execution, Property 11: 节点执行状态转换正确性
// Validates: Requirements 6.1, 6.2
[Property(MaxTest = 100)]
public Property ExecutionState_TransitionsProduceCorrectBoolProperties()
{
var gen =
from xm in ArbMap.Default.GeneratorFor<double>()
from ym in ArbMap.Default.GeneratorFor<double>()
select new ReferencePointNode(
Guid.NewGuid(), 0, "TestNode",
xm, ym, 0, 0, 0, 0, false, 0, 0);
return Prop.ForAll(
gen.ToArbitrary(),
node =>
{
var vm = new CncNodeViewModel(node, (vm2, n) => { });
// Running
vm.ExecutionState = NodeExecutionState.Running;
bool runningOk = vm.IsRunningNode == true
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == false;
// Succeeded
vm.ExecutionState = NodeExecutionState.Succeeded;
bool succeededOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == true
&& vm.IsFailedNode == false;
// Failed
vm.ExecutionState = NodeExecutionState.Failed;
bool failedOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == true;
// Idle
vm.ExecutionState = NodeExecutionState.Idle;
bool idleOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == false;
return runningOk && succeededOk && failedOk && idleOk;
});
}
}
}