gewuyou ff553977e3 chore(license): 补齐 Apache-2.0 文件头治理
- 新增许可证文件头检查与修复脚本

- 补充维护者手动修复 PR 工作流和 CI 校验

- 更新贡献指南中的文件头说明

- 补齐仓库维护源码和配置文件的许可证声明
2026-05-03 19:39:49 +08:00

87 lines
2.1 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.

// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
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);
}
}
}