PkmnLibRSharp/PkmnLibRSharpTests/StaticData/Libraries/AbilityLibraryTests.cs

51 lines
1.4 KiB
C#

using System;
using NUnit.Framework;
using PkmnLibSharp.StaticData;
using PkmnLibSharp.StaticData.Libraries;
namespace PkmnLibRSharpTests.StaticData.Libraries
{
public class AbilityLibraryTests
{
[Test]
public void Create()
{
var lib = AbilityLibrary.Create(0);
Assert.AreEqual(0, lib.Count);
}
[Test]
public void CreateAndAdd()
{
var lib = AbilityLibrary.Create(0);
Assert.AreEqual(0, lib.Count);
var ability = Ability.Create("testAbility", "effect", Array.Empty<EffectParameter>());
lib.Add("foobar", ability);
Assert.AreEqual(1, lib.Count);
Assert.AreEqual("testAbility", lib["foobar"].Name);
}
[Test]
public void CreateAddIterate()
{
var lib = AbilityLibrary.Create(0);
Assert.AreEqual(0, lib.Count);
for (ushort i = 0; i < 10; i++)
{
var item = Ability.Create(i.ToString(), "effect", Array.Empty<EffectParameter>());
lib.Add(i + "_key", item);
}
Assert.AreEqual(10, lib.Count);
var index = 0;
foreach (var kv in lib)
{
Assert.AreEqual(kv.Key, index + "_key");
Assert.AreEqual(kv.Value.Name, index.ToString());
index++;
}
Assert.AreEqual(10, index);
}
}
}