feat: resolve character figures from config
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using XGame;
|
||||
|
||||
public sealed class CharacterConfigDataTests
|
||||
{
|
||||
private static CharacterConfigData CreateConfig()
|
||||
{
|
||||
return new CharacterConfigData
|
||||
{
|
||||
defaultCharacterId = "Assasin",
|
||||
characters = new List<CharacterConfigItem>
|
||||
{
|
||||
new CharacterConfigItem { id = "Assasin", prefabPath = "Assets/Game/Art/Actor/Prefab/Assasin.prefab" },
|
||||
new CharacterConfigItem { id = "bls", prefabPath = "Assets/Game/Art/Actor/Prefab/bls.prefab" },
|
||||
new CharacterConfigItem { id = "boy", prefabPath = "Assets/Game/Art/Actor/Prefab/boy.prefab" },
|
||||
new CharacterConfigItem { id = "captain", prefabPath = "Assets/Game/Art/Actor/Prefab/captain.prefab" },
|
||||
new CharacterConfigItem { id = "cityboy_sk", prefabPath = "Assets/Game/Art/Actor/Prefab/cityboy_sk.prefab" },
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetFigureReturnsGeneratedListIndexForCityboy()
|
||||
{
|
||||
Assert.That(CreateConfig().GetFigure("cityboy_sk"), Is.EqualTo(5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetFigureUsesDefaultForAnUnknownId()
|
||||
{
|
||||
Assert.That(CreateConfig().GetFigure("missing"), Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetByFigureReturnsTheConfiguredPrefabPath()
|
||||
{
|
||||
CharacterConfigItem item = CreateConfig().GetByFigure(5);
|
||||
|
||||
Assert.That(item.id, Is.EqualTo("cityboy_sk"));
|
||||
Assert.That(item.prefabPath, Is.EqualTo("Assets/Game/Art/Actor/Prefab/cityboy_sk.prefab"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetByFigureUsesDefaultForAnInvalidIndex()
|
||||
{
|
||||
Assert.That(CreateConfig().GetByFigure(99).id, Is.EqualTo("Assasin"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptyConfigHasNoUsableFigure()
|
||||
{
|
||||
CharacterConfigData config = new CharacterConfigData();
|
||||
|
||||
Assert.That(config.GetFigure("cityboy_sk"), Is.EqualTo(0));
|
||||
Assert.That(config.GetByFigure(1), Is.Null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user