PkmnLibSharp/PkmnLibSharpTests/Library/SpeciesTests.cs

147 lines
7.3 KiB
C#
Raw Normal View History

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