GFramework/GFramework.Game.Tests/Config/YamlConfigTableRegistrationOptionsTests.cs
gewuyou ff553977e3 chore(license): 补齐 Apache-2.0 文件头治理
- 新增许可证文件头检查与修复脚本

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

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

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

49 lines
1.7 KiB
C#

// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
using GFramework.Game.Config;
namespace GFramework.Game.Tests.Config;
/// <summary>
/// 验证 YAML 配置表注册选项会在构造阶段建立最小不变量,避免非法路径状态继续向后传播。
/// </summary>
[TestFixture]
public class YamlConfigTableRegistrationOptionsTests
{
/// <summary>
/// 验证构造函数会拒绝空的或仅空白字符的表名。
/// </summary>
/// <param name="tableName">待验证的表名。</param>
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
public void Constructor_Should_Throw_When_Table_Name_Is_Null_Or_Whitespace(string? tableName)
{
var exception = Assert.Throws<ArgumentException>(() =>
_ = new YamlConfigTableRegistrationOptions<int, string>(
tableName!,
"monster",
static config => config.Length));
Assert.That(exception!.ParamName, Is.EqualTo("tableName"));
}
/// <summary>
/// 验证构造函数会拒绝空的或仅空白字符的相对目录路径。
/// </summary>
/// <param name="relativePath">待验证的相对目录路径。</param>
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
public void Constructor_Should_Throw_When_Relative_Path_Is_Null_Or_Whitespace(string? relativePath)
{
var exception = Assert.Throws<ArgumentException>(() =>
_ = new YamlConfigTableRegistrationOptions<int, string>(
"monster",
relativePath!,
static config => config.Length));
Assert.That(exception!.ParamName, Is.EqualTo("relativePath"));
}
}