feat(ai): BrainBuilder.RequireState——未声明状态挂边时构建期报错

This commit is contained in:
2026-07-29 11:08:23 +08:00
parent 8d63525b12
commit e76d6bc118
2 changed files with 27 additions and 0 deletions
@@ -69,5 +69,21 @@ namespace BaseGames.Tests.EditMode.AI
b.State("A").To("Nonexistent").When(c => true);
Assert.Throws<System.InvalidOperationException>(() => b.Build());
}
[Test]
public void RequireState_Throws_WhenStateNotDeclared()
{
var b = new BrainBuilder();
var ex = Assert.Throws<System.InvalidOperationException>(() => b.RequireState("Ghost"));
StringAssert.Contains("Ghost", ex.Message);
}
[Test]
public void RequireState_Passes_WhenStateDeclared()
{
var b = new BrainBuilder();
b.State("Real");
Assert.DoesNotThrow(() => b.RequireState("Real"));
}
}
}