mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 将所有小写的命名空间导入更正为首字母大写格式 - 统一 GFramework 框架的命名空间引用规范 - 修复 core、ecs、godot 等模块的命名空间导入错误 - 标准化文档示例代码中的 using 语句格式 - 确保所有文档中的命名空间引用保持一致性 - 更新 global using 语句以匹配正确的命名空间格式
84 lines
2.0 KiB
C#
84 lines
2.0 KiB
C#
using GFramework.Core.Coroutine.Instructions;
|
||
using NUnit.Framework;
|
||
|
||
namespace GFramework.Core.Tests.Coroutine
|
||
{
|
||
/// <summary>
|
||
/// Delay类的单元测试,用于验证延迟指令的功能
|
||
/// </summary>
|
||
[TestFixture]
|
||
public class DelayTests
|
||
{
|
||
/// <summary>
|
||
/// 测试构造函数设置初始剩余时间
|
||
/// </summary>
|
||
[Test]
|
||
public void Constructor_SetsInitialRemainingTime()
|
||
{
|
||
// Arrange & Act
|
||
var delay = new Delay(2.5);
|
||
|
||
// Assert
|
||
Assert.That(delay.IsDone, Is.False);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 测试Update方法减少剩余时间
|
||
/// </summary>
|
||
[Test]
|
||
public void Update_ReducesRemainingTime()
|
||
{
|
||
// Arrange
|
||
var delay = new Delay(2.0);
|
||
|
||
// Act
|
||
delay.Update(0.5);
|
||
|
||
// Assert
|
||
Assert.That(delay.IsDone, Is.False);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 测试多次Update后最终完成
|
||
/// </summary>
|
||
[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);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 测试负数时间被视为零
|
||
/// </summary>
|
||
[Test]
|
||
public void NegativeTime_TreatedAsZero()
|
||
{
|
||
// Arrange & Act
|
||
var delay = new Delay(-1.0);
|
||
|
||
// Assert
|
||
Assert.That(delay.IsDone, Is.True);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 测试零时间立即完成
|
||
/// </summary>
|
||
[Test]
|
||
public void ZeroTime_CompletesImmediately()
|
||
{
|
||
// Arrange & Act
|
||
var delay = new Delay(0.0);
|
||
|
||
// Assert
|
||
Assert.That(delay.IsDone, Is.True);
|
||
}
|
||
}
|
||
} |