PkmnLibSharp/PkmnLibSharpTests/Library/SpeciesTests.cs

113 lines
4.8 KiB
C#
Raw Normal View History

2020-05-03 14:26:14 +00:00
using NUnit.Framework;
using PkmnLibSharp.Library;
2020-05-04 19:16:42 +00:00
using PkmnLibSharp.Utilities;
2020-05-03 14:26:14 +00:00
namespace PkmnLibSharpTests.Library
{
public class SpeciesTests
{
[Test]
public void ConstructDestruct()
{
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);
species.Dispose();
}
2020-05-04 19:16:42 +00:00
[Test]
public void GetId()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.AreEqual(10, species.Id);
species.Dispose();
}
[Test]
public void GetGenderRate()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.AreEqual(0.5f, species.GenderRate);
species.Dispose();
}
[Test]
public void GetCaptureRate()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.AreEqual(100, species.CaptureRate);
species.Dispose();
}
[Test]
public void GetName()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.AreEqual("testSpecies", species.Name);
species.Dispose();
}
[Test]
public void GetGrowthRate()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.AreEqual("exponential", species.GrowthRate);
species.Dispose();
}
[Test]
public void HasForme()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.True(species.HasForme("default"));
species.Dispose();
}
[Test]
public void SetForme()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.True(species.HasForme("default"));
forme = Forme.Create("bar", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, LearnableMoves.Create(100));
species.SetForme("bar", forme);
Assert.True(species.HasForme("bar"));
species.Dispose();
}
[Test]
public void GetForme()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
var f = species.GetForme("default");
Assert.AreEqual(forme, f);
Assert.Throws<NativeException>(() =>
{
species.GetForme("non-existing");
});
species.Dispose();
}
[Test]
public void TrGetForme()
{
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(10, "testSpecies", forme, 0.5f, "exponential", 100, 80);
Assert.True(species.TryGetForme("default", out var f));
Assert.AreEqual(forme, f);
Assert.False(species.TryGetForme("non-existing", out f));
species.Dispose();
}
2020-05-03 14:26:14 +00:00
}
}