test(core-tests): 简化结果与协程异步断言包装

- 简化 ResultExtensionsTests 中的异步异常断言包装
- 更新 AsyncOperationTests 的 Task 断言写法以消除低风险 analyzer 噪音
This commit is contained in:
gewuyou 2026-04-25 09:55:10 +08:00
parent ffd62bb475
commit 65cd23ff3e
2 changed files with 3 additions and 3 deletions

View File

@ -104,7 +104,7 @@ public class AsyncOperationTests
op.SetException(expectedException); op.SetException(expectedException);
Assert.That(async () => await op.Task, Throws.InstanceOf<InvalidOperationException>()); Assert.That(() => op.Task, Throws.InstanceOf<InvalidOperationException>());
} }
/// <summary> /// <summary>

View File

@ -487,7 +487,7 @@ public class ResultExtensionsTests
[Test] [Test]
public void TryAsync_Should_Throw_ArgumentNullException_When_Function_Is_Null() public void TryAsync_Should_Throw_ArgumentNullException_When_Function_Is_Null()
{ {
Assert.ThrowsAsync<ArgumentNullException>(async () => await ResultExtensions.TryAsync<int>(null!)); Assert.ThrowsAsync<ArgumentNullException>(() => ResultExtensions.TryAsync<int>(null!));
} }
/// <summary> /// <summary>