76 lines
2.8 KiB
C#
76 lines
2.8 KiB
C#
|
using NUnit.Framework;
|
||
|
using PkmnLibSharp.Library;
|
||
|
using PkmnLibSharp.Utilities;
|
||
|
|
||
|
namespace PkmnLibSharpTests.Library
|
||
|
{
|
||
|
public class SpeciesLibraryTests
|
||
|
{
|
||
|
[Test]
|
||
|
public void ConstructDestruct()
|
||
|
{
|
||
|
var item = new SpeciesLibrary(100);
|
||
|
item.Dispose();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Insert()
|
||
|
{
|
||
|
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||
|
new[] {"bar"}, LearnableMoves.Create(100));
|
||
|
var species = Species.Create(0, "testSpecies", forme, 0.5f, "exponential", 100, 80);
|
||
|
var library = new SpeciesLibrary(100);
|
||
|
library.Insert("foobar", species);
|
||
|
Assert.AreEqual(1, library.Count);
|
||
|
library.Dispose();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Delete()
|
||
|
{
|
||
|
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||
|
new[] {"bar"}, LearnableMoves.Create(100));
|
||
|
var species = Species.Create(0, "testSpecies", forme, 0.5f, "exponential", 100, 80);
|
||
|
var library = new SpeciesLibrary(100);
|
||
|
library.Insert("foobar", species);
|
||
|
Assert.AreEqual(1, library.Count);
|
||
|
library.Delete("foobar");
|
||
|
Assert.AreEqual(0, library.Count);
|
||
|
library.Dispose();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Get()
|
||
|
{
|
||
|
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||
|
new[] {"bar"}, LearnableMoves.Create(100));
|
||
|
var species = Species.Create(0, "testSpecies", forme, 0.5f, "exponential", 100, 80);
|
||
|
var library = new SpeciesLibrary(100);
|
||
|
library.Insert("foobar", species);
|
||
|
Assert.AreEqual(1, library.Count);
|
||
|
var m = library.Get("foobar");
|
||
|
Assert.AreEqual(m.Name, "testSpecies");
|
||
|
Assert.Throws<NativeException>(() =>
|
||
|
{
|
||
|
library.Get("barfoo");
|
||
|
});
|
||
|
library.Dispose();
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void TryGet()
|
||
|
{
|
||
|
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||
|
new[] {"bar"}, LearnableMoves.Create(100));
|
||
|
var species = Species.Create(0, "testSpecies", forme, 0.5f, "exponential", 100, 80);
|
||
|
var library = new SpeciesLibrary(100);
|
||
|
library.Insert("foobar", species);
|
||
|
Assert.AreEqual(1, library.Count);
|
||
|
Assert.True(library.TryGet("foobar", out species));
|
||
|
Assert.AreEqual(species.Name, "testSpecies");
|
||
|
Assert.False(library.TryGet("barfoo", out species));
|
||
|
library.Dispose();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|