test(state): 更新状态机上下文获取测试验证逻辑

- 将断言修改为验证 GetContext 方法抛出 InvalidOperationException 异常
- 在状态机初始化前验证状态上下文为空的预期行为
- 保持初始化后状态上下文正确设置的验证逻辑
This commit is contained in:
GeWuYou 2026-02-15 18:39:05 +08:00 committed by gewuyou
parent 703328deb2
commit 7e2a1ff66d

View File

@ -111,8 +111,8 @@ public class StateMachineSystemTests
_stateMachine!.Register(state1);
_stateMachine.Register(state2);
Assert.That(state1.GetContext(), Is.Null);
Assert.That(state2.GetContext(), Is.Null);
Assert.Throws<InvalidOperationException>(() => state1.GetContext());
Assert.Throws<InvalidOperationException>(() => state2.GetContext());
_stateMachine.Init();