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 = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"}, new[] {"bar"}, new LearnableMoves(100)); var species = new Species(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 = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"}, new[] {"bar"}, new LearnableMoves(100)); var species = new Species(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 = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"}, new[] {"bar"}, new LearnableMoves(100)); var species = new Species(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(() => { library.Get("barfoo"); }); library.Dispose(); } [Test] public void TryGet() { var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"}, new[] {"bar"}, new LearnableMoves(100)); var species = new Species(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(); } } }