GeWuYou 445513b784 docs(tests): 为测试文件添加XML文档注释
- 为AsyncExtensionsTests中的所有测试方法添加描述性注释
- 为CollectionExtensionsTests中的所有测试方法添加描述性注释
- 为DelayTests类和其中的测试方法添加描述性注释
- 为GuardExtensionsTests中的所有测试方法添加描述性注释
- 为MediatorComprehensiveTests中的所有测试方法添加描述性注释
- 为NumericExtensionsTests中的所有测试方法添加描述性注释
- 为OptionTests中的所有测试方法添加描述性注释
- 为PipeExtensionsTests中的所有测试方法添加描述性注释
2026-02-26 14:45:39 +08:00

84 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}