refactor(core-tests): 简化状态机异步断言包装

- 简化 StateMachineSystemTests 中的 Task 异常断言包装

- 简化 StateMachineTests 中的异步异常断言包装并保持测试语义不变
This commit is contained in:
gewuyou 2026-04-25 09:49:20 +08:00
parent 67c9359fd2
commit 0d8f854dd2
2 changed files with 3 additions and 3 deletions

View File

@ -138,7 +138,7 @@ public class StateMachineSystemTests
[Test]
public async Task DestroyAsync_Should_Not_Throw_Exception()
{
Assert.That(async () => await _stateMachine!.DestroyAsync(), Throws.Nothing);
Assert.That(() => _stateMachine!.DestroyAsync(), Throws.Nothing);
}
/// <summary>

View File

@ -216,7 +216,7 @@ public class StateMachineTests
[Test]
public void ChangeToAsync_ToUnregisteredState_Should_ThrowInvalidOperationException()
{
Assert.ThrowsAsync<InvalidOperationException>(async () => await _stateMachine.ChangeToAsync<TestStateV2>());
Assert.ThrowsAsync<InvalidOperationException>(() => _stateMachine.ChangeToAsync<TestStateV2>());
}
/// <summary>
@ -601,4 +601,4 @@ public static class StateMachineExtensions
.GetValue(stateMachine) is Dictionary<Type, IState> states &&
states.ContainsKey(typeof(T));
}
}
}