2021-11-27 10:27:19 +00:00
|
|
|
using System;
|
2020-05-04 19:16:42 +00:00
|
|
|
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()
|
|
|
|
{
|
2021-11-27 10:27:19 +00:00
|
|
|
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]);
|
2020-05-04 19:16:42 +00:00
|
|
|
var library = new SpeciesLibrary(100);
|
|
|
|
library.Insert("foobar", species);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
library.Dispose();
|
|
|
|
}
|
2021-11-27 10:27:19 +00:00
|
|
|
|
2020-05-04 19:16:42 +00:00
|
|
|
[Test]
|
|
|
|
public void Delete()
|
|
|
|
{
|
2021-11-27 10:27:19 +00:00
|
|
|
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]);
|
2020-05-04 19:16:42 +00:00
|
|
|
var library = new SpeciesLibrary(100);
|
|
|
|
library.Insert("foobar", species);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
library.Delete("foobar");
|
|
|
|
Assert.AreEqual(0, library.Count);
|
|
|
|
library.Dispose();
|
|
|
|
}
|
2021-11-27 10:27:19 +00:00
|
|
|
|
2020-05-04 19:16:42 +00:00
|
|
|
[Test]
|
|
|
|
public void Get()
|
|
|
|
{
|
2021-11-27 10:27:19 +00:00
|
|
|
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]);
|
2020-05-04 19:16:42 +00:00
|
|
|
var library = new SpeciesLibrary(100);
|
|
|
|
library.Insert("foobar", species);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
var m = library.Get("foobar");
|
|
|
|
Assert.AreEqual(m.Name, "testSpecies");
|
2021-11-27 10:27:19 +00:00
|
|
|
Assert.Throws<NativeException>(() => { library.Get("barfoo"); });
|
2020-05-04 19:16:42 +00:00
|
|
|
library.Dispose();
|
|
|
|
}
|
2021-11-27 10:27:19 +00:00
|
|
|
|
2020-05-04 19:16:42 +00:00
|
|
|
[Test]
|
|
|
|
public void TryGet()
|
|
|
|
{
|
2021-11-27 10:27:19 +00:00
|
|
|
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]);
|
2020-05-04 19:16:42 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|