CNC执行逻辑的开发,点击运行,停止

This commit is contained in:
zhengxuan.zhang
2026-04-27 16:18:47 +08:00
parent e24bfef3e6
commit 2a64d48b54
14 changed files with 1450 additions and 16 deletions
@@ -0,0 +1,54 @@
// 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.Services
{
public class CncNodeViewModelTests
{
// Feature: cnc-run-execution, Property 11: 节点执行状态转换正确性
// Validates: Requirements 6.1, 6.2
[Property(MaxTest = 100)]
public Property ExecutionState_DerivedBoolProperties_AreConsistent()
{
var gen =
from xm in ArbMap.Default.GeneratorFor<double>()
select new ReferencePointNode(
Guid.NewGuid(), 0, "TestNode",
xm, 0, 0, 0, 0, 0, false, 0, 0);
return Prop.ForAll(
gen.ToArbitrary(),
(ReferencePointNode node) =>
{
var vm = new CncNodeViewModel(node, (_, __) => { });
// Running state
vm.ExecutionState = NodeExecutionState.Running;
bool runningOk = vm.IsRunningNode == true
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == false;
// Succeeded state
vm.ExecutionState = NodeExecutionState.Succeeded;
bool succeededOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == true
&& vm.IsFailedNode == false;
// Idle state
vm.ExecutionState = NodeExecutionState.Idle;
bool idleOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == false;
return runningOk && succeededOk && idleOk;
});
}
}
}