diff --git a/AGENTS.md b/AGENTS.md index 7f9fb3c1..4e39ad22 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -123,6 +123,8 @@ All generated or modified code MUST include clear and meaningful comments where - Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical. - Public API changes must be covered by unit or integration tests. +- When a public API defines multiple contract branches, tests MUST cover the meaningful variants, including null, + empty, default, and filtered inputs when those branches change behavior. - Regression fixes should include a test that fails before the fix and passes after it. ### Test Organization diff --git a/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs b/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs index 48c1a763..a80a1990 100644 --- a/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs +++ b/GFramework.Game.Tests/Config/GeneratedConfigConsumerIntegrationTests.cs @@ -138,6 +138,16 @@ public class GeneratedConfigConsumerIntegrationTests }); await tableNameLoader.LoadAsync(tableNameRegistry); + var emptyAllowListRegistry = new ConfigRegistry(); + var emptyAllowListLoader = new YamlConfigLoader(_rootPath) + .RegisterAllGeneratedConfigTables( + new GeneratedConfigRegistrationOptions + { + IncludedConfigDomains = Array.Empty(), + IncludedTableNames = Array.Empty() + }); + await emptyAllowListLoader.LoadAsync(emptyAllowListRegistry); + var monsterDomain = MonsterConfigBindings.ConfigDomain; var predicateRegistry = new ConfigRegistry(); var predicateLoader = new YamlConfigLoader(_rootPath) @@ -151,6 +161,11 @@ public class GeneratedConfigConsumerIntegrationTests Assert.Multiple(() => { + Assert.That(emptyAllowListRegistry.TryGetMonsterTable(out var emptyAllowListMonsterTable), Is.True); + Assert.That(emptyAllowListMonsterTable, Is.Not.Null); + Assert.That(emptyAllowListRegistry.TryGetItemTable(out var emptyAllowListItemTable), Is.True); + Assert.That(emptyAllowListItemTable, Is.Not.Null); + Assert.That(domainRegistry.TryGetMonsterTable(out var domainMonsterTable), Is.True); Assert.That(domainMonsterTable, Is.Not.Null); Assert.That(domainRegistry.TryGetItemTable(out _), Is.False);