test(ai): 补测经 AiStateFragments 的跨模块状态撞名,State() 补引导注释
This commit is contained in:
@@ -114,5 +114,27 @@ namespace BaseGames.Tests.EditMode.AI
|
||||
var b = new BrainBuilder();
|
||||
Assert.Throws<System.ArgumentException>(() => AiStateFragments.AbilityOnce(b, "S", null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Fragments_Throw_WhenTwoModulesDeclareSameState()
|
||||
{
|
||||
// 守卫存在的真正理由:两个独立模块取了同名状态时,
|
||||
// 后者的回调会静默覆盖前者。经原语声明必须直接报错。
|
||||
var b = new BrainBuilder();
|
||||
AiStateFragments.Locomotion(b, "Idle", LocomotionMode.Idle);
|
||||
var ex = Assert.Throws<System.InvalidOperationException>(
|
||||
() => AiStateFragments.Locomotion(b, "Idle", LocomotionMode.Patrol));
|
||||
StringAssert.Contains("Idle", ex.Message);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Fragments_Throw_WhenDifferentFragmentKindsCollide()
|
||||
{
|
||||
// 跨层撞名同样要挡:未发现层的 Locomotion 态与死亡层的 Ability 态重名。
|
||||
var b = new BrainBuilder();
|
||||
AiStateFragments.Locomotion(b, "Shared", LocomotionMode.Patrol);
|
||||
Assert.Throws<System.InvalidOperationException>(
|
||||
() => AiStateFragments.Ability(b, "Shared", "atk"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user