mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 为 Delay 指令添加完整的单元测试覆盖各种时间情况 - 为 WaitForCoroutine 指令添加单元测试验证协程等待功能 - 为 WaitForFrames 指令添加单元测试覆盖帧计数逻辑 - 为 WaitForTask<T> 指令添加单元测试包括异常处理场景 - 为 WaitOneFrame 指令添加单元测试验证单帧等待 - 为 WaitUntil 和 WaitWhile 指令添加单元测试覆盖谓词逻辑 - 将 WaitForMultipleEventsTests 中的异步方法标记为 async Task 类型 - 修改测试事件类的 Data 属性为可变的 set 访问器而不是只读 init - 优化 WaitForMultipleEventsTests 中的断言注释描述
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using GFramework.Core.coroutine.instructions;
|
|
using NUnit.Framework;
|
|
|
|
namespace GFramework.Core.Tests.coroutine
|
|
{
|
|
[TestFixture]
|
|
public class WaitWhileTests
|
|
{
|
|
[Test]
|
|
public void Constructor_WithNullPredicate_ThrowsArgumentNullException()
|
|
{
|
|
// Act & Assert
|
|
Assert.Throws<ArgumentNullException>(() => new WaitWhile(null!));
|
|
}
|
|
|
|
[Test]
|
|
public void IsDone_ReturnsInverseOfPredicateResult_True()
|
|
{
|
|
// Arrange
|
|
var condition = true;
|
|
var waitWhile = new WaitWhile(() => condition);
|
|
|
|
// Act
|
|
condition = false;
|
|
|
|
// Assert
|
|
Assert.That(waitWhile.IsDone, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void IsDone_ReturnsInverseOfPredicateResult_False()
|
|
{
|
|
// Arrange
|
|
var condition = false;
|
|
var waitWhile = new WaitWhile(() => condition);
|
|
|
|
// Assert
|
|
Assert.That(waitWhile.IsDone, Is.True); // Because !false = true
|
|
}
|
|
|
|
[Test]
|
|
public void IsDone_WhenPredicateReturnsTrue()
|
|
{
|
|
// Arrange
|
|
var condition = true;
|
|
var waitWhile = new WaitWhile(() => condition);
|
|
|
|
// Assert
|
|
Assert.That(waitWhile.IsDone, Is.False); // Because !true = false
|
|
}
|
|
|
|
[Test]
|
|
public void Update_DoesNotChangeState()
|
|
{
|
|
// Arrange
|
|
var condition = true;
|
|
var waitWhile = new WaitWhile(() => condition);
|
|
|
|
// Act
|
|
waitWhile.Update(0.1);
|
|
|
|
// Assert
|
|
Assert.That(waitWhile.IsDone, Is.False);
|
|
}
|
|
}
|
|
} |