From 0d8f854dd2842020e56ee317ae1837bb27359fd0 Mon Sep 17 00:00:00 2001 From: gewuyou <95328647+GeWuYou@users.noreply.github.com> Date: Sat, 25 Apr 2026 09:49:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(core-tests):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9C=BA=E5=BC=82=E6=AD=A5=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E5=8C=85=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 简化 StateMachineSystemTests 中的 Task 异常断言包装 - 简化 StateMachineTests 中的异步异常断言包装并保持测试语义不变 --- GFramework.Core.Tests/State/StateMachineSystemTests.cs | 2 +- GFramework.Core.Tests/State/StateMachineTests.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GFramework.Core.Tests/State/StateMachineSystemTests.cs b/GFramework.Core.Tests/State/StateMachineSystemTests.cs index 9ee084ff..58d818e3 100644 --- a/GFramework.Core.Tests/State/StateMachineSystemTests.cs +++ b/GFramework.Core.Tests/State/StateMachineSystemTests.cs @@ -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); } /// diff --git a/GFramework.Core.Tests/State/StateMachineTests.cs b/GFramework.Core.Tests/State/StateMachineTests.cs index 3f854ade..a9f17a50 100644 --- a/GFramework.Core.Tests/State/StateMachineTests.cs +++ b/GFramework.Core.Tests/State/StateMachineTests.cs @@ -216,7 +216,7 @@ public class StateMachineTests [Test] public void ChangeToAsync_ToUnregisteredState_Should_ThrowInvalidOperationException() { - Assert.ThrowsAsync(async () => await _stateMachine.ChangeToAsync()); + Assert.ThrowsAsync(() => _stateMachine.ChangeToAsync()); } /// @@ -601,4 +601,4 @@ public static class StateMachineExtensions .GetValue(stateMachine) is Dictionary states && states.ContainsKey(typeof(T)); } -} \ No newline at end of file +}