GFramework/GFramework.Godot.Tests/Text/RichTextMarkupTests.cs
GeWuYou e5ad29314e feat(text): 添加富文本效果系统和颜色标记功能
- 实现 RichTextEffectBase 基类提供统一的标签命名和参数读取逻辑
- 添加 RichTextBlueEffect、RichTextGoldEffect、RichTextGreenEffect 和 RichTextRedEffect 颜色标记效果
- 添加 RichTextFadeInEffect、RichTextFlyInEffect、RichTextJitterEffect 和 RichTextSineEffect 动画效果
- 实现 DefaultRichTextEffectRegistry 默认效果注册表
- 创建 GfRichTextLabel 富文本标签宿主组件
- 添加 IRichTextEffectRegistry 效果注册表接口
- 实现 RichTextEffectEntry、RichTextEffectsController 和 RichTextProfile 配置管理类
- 添加 RichTextMarkup 语义化标签构建辅助方法
- 创建 RichTextMarkupTests 和 RichTextProfileTests 单元测试
2026-04-18 11:58:40 +08:00

39 lines
979 B
C#

using GFramework.Godot.Text;
namespace GFramework.Godot.Tests.Text;
/// <summary>
/// <see cref="RichTextMarkup" /> 的测试。
/// </summary>
[TestFixture]
public sealed class RichTextMarkupTests
{
/// <summary>
/// 验证颜色快捷方法会输出预期标签。
/// </summary>
[Test]
public void Green_Should_Wrap_Text_With_Green_Tag()
{
var result = RichTextMarkup.Green("Ready");
Assert.That(result, Is.EqualTo("[green]Ready[/green]"));
}
/// <summary>
/// 验证效果方法会按稳定顺序拼接环境参数。
/// </summary>
[Test]
public void Effect_Should_Append_Environment_Parameters()
{
var env = new Dictionary<string, object?>
{
["speed"] = 4,
["tick"] = 0.1f
};
var result = RichTextMarkup.Effect("Hello", "fade_in", env);
Assert.That(result, Is.EqualTo("[fade_in speed=4 tick=0.1]Hello[/fade_in]"));
}
}