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.5 KiB
C#
66 lines
1.5 KiB
C#
using GFramework.Core.coroutine.instructions;
|
|
using NUnit.Framework;
|
|
|
|
namespace GFramework.Core.Tests.coroutine
|
|
{
|
|
[TestFixture]
|
|
public class DelayTests
|
|
{
|
|
[Test]
|
|
public void Constructor_SetsInitialRemainingTime()
|
|
{
|
|
// Arrange & Act
|
|
var delay = new Delay(2.5);
|
|
|
|
// Assert
|
|
Assert.That(delay.IsDone, Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void Update_ReducesRemainingTime()
|
|
{
|
|
// Arrange
|
|
var delay = new Delay(2.0);
|
|
|
|
// Act
|
|
delay.Update(0.5);
|
|
|
|
// Assert
|
|
Assert.That(delay.IsDone, Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void Update_MultipleTimes_EventuallyCompletes()
|
|
{
|
|
// Arrange
|
|
var delay = new Delay(1.0);
|
|
|
|
// Act
|
|
delay.Update(0.5);
|
|
delay.Update(0.6); // Total: 1.1 > 1.0, so should be done
|
|
|
|
// Assert
|
|
Assert.That(delay.IsDone, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void NegativeTime_TreatedAsZero()
|
|
{
|
|
// Arrange & Act
|
|
var delay = new Delay(-1.0);
|
|
|
|
// Assert
|
|
Assert.That(delay.IsDone, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void ZeroTime_CompletesImmediately()
|
|
{
|
|
// Arrange & Act
|
|
var delay = new Delay(0.0);
|
|
|
|
// Assert
|
|
Assert.That(delay.IsDone, Is.True);
|
|
}
|
|
}
|
|
} |