86 lines
3.8 KiB
C#
86 lines
3.8 KiB
C#
using System;
|
|
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()
|
|
{
|
|
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
|
|
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
|
|
|
|
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
|
|
new[] { ability2 }, new LearnableMoves(100), new string[0]);
|
|
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
|
|
new string[0]);
|
|
var library = new SpeciesLibrary(100);
|
|
library.Insert("foobar", species);
|
|
Assert.AreEqual(1, library.Count);
|
|
library.Dispose();
|
|
}
|
|
|
|
[Test]
|
|
public void Delete()
|
|
{
|
|
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
|
|
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
|
|
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
|
|
new[] { ability2 }, new LearnableMoves(100), new string[0]);
|
|
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
|
|
new string[0]);
|
|
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()
|
|
{
|
|
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
|
|
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
|
|
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
|
|
new[] { ability2 }, new LearnableMoves(100), new string[0]);
|
|
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
|
|
new string[0]);
|
|
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()
|
|
{
|
|
using var ability1 = new Ability("foo", "foo", Array.Empty<EffectParameter>());
|
|
using var ability2 = new Ability("bar", "bar", Array.Empty<EffectParameter>());
|
|
var forme = new Forme("foo", 1, 2, 100, new byte[] { 0 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
|
|
new[] { ability2 }, new LearnableMoves(100), new string[0]);
|
|
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[] { "testEggGroup" },
|
|
new string[0]);
|
|
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();
|
|
}
|
|
}
|
|
} |