60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using NUnit.Framework;
|
|
using UnityEngine;
|
|
using BaseGames.Enemies.Abilities;
|
|
|
|
namespace BaseGames.Tests.EditMode.AI
|
|
{
|
|
public class AbilityRefTests
|
|
{
|
|
[Test]
|
|
public void ImplicitFromString_ExposesLiteralId()
|
|
{
|
|
AbilityRef r = "e001_chase";
|
|
Assert.AreEqual("e001_chase", r.Id);
|
|
Assert.IsFalse(r.IsEmpty);
|
|
}
|
|
|
|
[Test]
|
|
public void FromAsset_ExposesAssetAbilityId()
|
|
{
|
|
var so = ScriptableObject.CreateInstance<EnemyAbilitySO>();
|
|
so.abilityId = "from_asset";
|
|
AbilityRef r = so;
|
|
Assert.AreEqual("from_asset", r.Id);
|
|
Object.DestroyImmediate(so);
|
|
}
|
|
|
|
[Test]
|
|
public void Default_IsEmpty()
|
|
{
|
|
var r = default(AbilityRef);
|
|
Assert.IsTrue(r.IsEmpty);
|
|
Assert.IsNull(r.Id);
|
|
}
|
|
|
|
[Test]
|
|
public void AssetWins_WhenBothSet()
|
|
{
|
|
var so = ScriptableObject.CreateInstance<EnemyAbilitySO>();
|
|
so.abilityId = "asset_id";
|
|
var r = new AbilityRef(so, "literal_id");
|
|
Assert.AreEqual("asset_id", r.Id);
|
|
Assert.IsTrue(r.HasConflict); // 供校验器报警告
|
|
Object.DestroyImmediate(so);
|
|
}
|
|
|
|
[Test]
|
|
public void AssetWithEmptyId_IsEmpty()
|
|
{
|
|
// 资产挂了但其 abilityId 没填——校验器要能抓到的误配路径,
|
|
// 此处钉住契约:IsEmpty 为真、Id 为空,不因"挂了资产"就当作已配置。
|
|
var so = ScriptableObject.CreateInstance<EnemyAbilitySO>();
|
|
so.abilityId = "";
|
|
AbilityRef r = so;
|
|
Assert.IsTrue(r.IsEmpty);
|
|
Assert.IsEmpty(r.Id);
|
|
Object.DestroyImmediate(so);
|
|
}
|
|
}
|
|
}
|