PkmnLibSharp/PkmnLibSharpTests/Library/SpeciesTests.cs

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