PkmnLibSharp/PkmnLibSharpTests/Library/SpeciesTests.cs

147 lines
7.3 KiB
C#

using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharpTests.Library
{
public class SpeciesTests
{
[Test]
public void ConstructDestruct()
{
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]);
species.Dispose();
}
[Test]
public void GetId()
{
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]);
Assert.AreEqual(10, species.Id);
species.Dispose();
}
[Test]
public void GetGenderRate()
{
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]);
Assert.AreEqual(0.5f, species.GenderRate);
species.Dispose();
}
[Test]
public void GetCaptureRate()
{
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]);
Assert.AreEqual(100, species.CaptureRate);
species.Dispose();
}
[Test]
public void GetName()
{
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]);
Assert.AreEqual("testSpecies", species.Name);
species.Dispose();
}
[Test]
public void GetGrowthRate()
{
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]);
Assert.AreEqual("exponential", species.GrowthRate);
species.Dispose();
}
[Test]
public void HasForme()
{
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]);
Assert.True(species.HasForme("default"));
species.Dispose();
}
[Test]
public void SetForme()
{
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]);
Assert.True(species.HasForme("default"));
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]);
species.SetForme("bar", forme);
Assert.True(species.HasForme("bar"));
species.Dispose();
}
[Test]
public void GetForme()
{
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]);
var f = species.GetForme("default");
Assert.AreEqual(forme, f);
Assert.Throws<NativeException>(() => { species.GetForme("non-existing"); });
species.Dispose();
}
[Test]
public void TryGetForme()
{
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]);
Assert.True(species.TryGetForme("default", out var f));
Assert.AreEqual(forme, f);
Assert.False(species.TryGetForme("non-existing", out f));
species.Dispose();
}
}
}