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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47b7140934731c5468fc9a11064a59b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "XWorld.Link.EditModeTests",
|
||||
"rootNamespace": "",
|
||||
"references": ["XWorld.Link"],
|
||||
"includePlatforms": ["Editor"],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false,
|
||||
"optionalUnityReferences": ["TestAssemblies"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8a5f61959a9cf247820e4e20a9ba310
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user