在现有的 位置节点属性中新增一个 checkbox 按钮,来确认是否保存图片

This commit is contained in:
zhengxuan.zhang
2026-05-14 17:04:29 +08:00
parent ca22f59447
commit d3e75f3fac
10 changed files with 141 additions and 44 deletions
@@ -7,15 +7,25 @@ using FsCheck.Fluent;
using FsCheck.Xunit;
using XplorePlane.Models;
using XplorePlane.ViewModels.Cnc;
using Xunit;
namespace XplorePlane.Tests.ViewModels
{
public class CncNodeViewModelTests
{
// ── Property 11: 节点执行状态转换正确性 ──────────────────────────────
[Fact]
public void SavePosition_SaveImage_CanBeUpdated()
{
var node = new SavePositionNode(Guid.NewGuid(), 0, "Pos_0", MotionState.Default, SaveImage: false);
var vm = new CncNodeViewModel(node, (_, __) => { });
vm.SaveImage = true;
var updatedNode = Assert.IsType<SavePositionNode>(vm.Model);
Assert.True(vm.SaveImage);
Assert.True(updatedNode.SaveImage);
}
// Feature: cnc-run-execution, Property 11: 节点执行状态转换正确性
// Validates: Requirements 6.1, 6.2
[Property(MaxTest = 100)]
public Property ExecutionState_TransitionsProduceCorrectBoolProperties()
{
@@ -30,31 +40,27 @@ namespace XplorePlane.Tests.ViewModels
gen.ToArbitrary(),
node =>
{
var vm = new CncNodeViewModel(node, (vm2, n) => { });
var vm = new CncNodeViewModel(node, (_, __) => { });
// Running
vm.ExecutionState = NodeExecutionState.Running;
bool runningOk = vm.IsRunningNode == true
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == false;
bool runningOk = vm.IsRunningNode
&& !vm.IsSucceededNode
&& !vm.IsFailedNode;
// Succeeded
vm.ExecutionState = NodeExecutionState.Succeeded;
bool succeededOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == true
&& vm.IsFailedNode == false;
bool succeededOk = !vm.IsRunningNode
&& vm.IsSucceededNode
&& !vm.IsFailedNode;
// Failed
vm.ExecutionState = NodeExecutionState.Failed;
bool failedOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == true;
bool failedOk = !vm.IsRunningNode
&& !vm.IsSucceededNode
&& vm.IsFailedNode;
// Idle
vm.ExecutionState = NodeExecutionState.Idle;
bool idleOk = vm.IsRunningNode == false
&& vm.IsSucceededNode == false
&& vm.IsFailedNode == false;
bool idleOk = !vm.IsRunningNode
&& !vm.IsSucceededNode
&& !vm.IsFailedNode;
return runningOk && succeededOk && failedOk && idleOk;
});