57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
using System;
|
|
using NUnit.Framework;
|
|
using PkmnLibSharp.StaticData;
|
|
using PkmnLibSharp.StaticData.Libraries;
|
|
|
|
namespace PkmnLibRSharpTests.StaticData.Libraries
|
|
{
|
|
public class SpeciesLibraryTests
|
|
{
|
|
[Test]
|
|
public void Create()
|
|
{
|
|
var lib = SpeciesLibrary.Create(0);
|
|
Assert.AreEqual(0, lib.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateAndAdd()
|
|
{
|
|
var lib = SpeciesLibrary.Create(1);
|
|
Assert.AreEqual(0, lib.Count);
|
|
var stats = StaticStatisticSet<ushort>.Create(5, 10, 30, 20, 2, 0);
|
|
var moves = LearnableMoves.Create();
|
|
var form = Form.Create("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
|
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
|
var species = Species.Create(10, "testSpecies", 0.2f, "growth", 120, form, Array.Empty<string>());
|
|
lib.Add("foobar", species);
|
|
Assert.AreEqual(1, lib.Count);
|
|
Assert.AreEqual("testSpecies", lib["foobar"].Name);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateAddIterate()
|
|
{
|
|
var lib = SpeciesLibrary.Create(1);
|
|
Assert.AreEqual(0, lib.Count);
|
|
for (ushort i = 0; i < 10; i++)
|
|
{
|
|
var stats = StaticStatisticSet<ushort>.Create(5, 10, 30, 20, 2, 0);
|
|
var moves = LearnableMoves.Create();
|
|
var form = Form.Create("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
|
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
|
var species = Species.Create(i, i.ToString(), 0.2f, "growth", 120, form, Array.Empty<string>());
|
|
lib.Add(i + "_key", species);
|
|
}
|
|
Assert.AreEqual(10, lib.Count);
|
|
var index = 0;
|
|
foreach (var kv in lib)
|
|
{
|
|
Assert.AreEqual(kv.Key, index + "_key");
|
|
Assert.AreEqual(kv.Value.Id, index);
|
|
index++;
|
|
}
|
|
Assert.AreEqual(10, index);
|
|
}
|
|
}
|
|
} |