57 lines
2.2 KiB
C#
57 lines
2.2 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()
|
|
{
|
|
using var lib = new SpeciesLibrary(0);
|
|
Assert.AreEqual(0, lib.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateAndAdd()
|
|
{
|
|
using var lib = new SpeciesLibrary(1);
|
|
Assert.AreEqual(0, lib.Count);
|
|
using var stats = new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0);
|
|
using var moves = new LearnableMoves();
|
|
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
|
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
|
using var species = new Species(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()
|
|
{
|
|
using var lib = new SpeciesLibrary(1);
|
|
Assert.AreEqual(0, lib.Count);
|
|
for (ushort i = 0; i < 10; i++)
|
|
{
|
|
using var stats = new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0);
|
|
using var moves = new LearnableMoves();
|
|
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
|
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
|
using var species = new Species(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);
|
|
}
|
|
}
|
|
} |