Update to latest version of pkmnLib.

This commit is contained in:
2021-11-27 11:27:19 +01:00
parent d542e75cd1
commit 382cbf2673
46 changed files with 642 additions and 342 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Linq;
using NUnit.Framework;
using PkmnLibSharp.Battling;
@@ -12,19 +13,18 @@ namespace PkmnLibSharpTests.Battling
{
private static BattleLibrary _cache;
private static readonly object Lock = new object();
public static BattleLibrary GetLibrary()
{
lock (Lock)
{
if (_cache != null)
if (_cache != null)
return _cache;
TestContext.WriteLine("Building battle library");
var scriptLibrary = new AngelScriptResolver();
_cache = new BattleLibrary(BuildStatic(), new StatCalculator(), new DamageLibrary(),
new ExperienceLibrary(),
scriptLibrary, new MiscLibrary(GetTime));
new ExperienceLibrary(), scriptLibrary, new MiscLibrary(GetTime));
scriptLibrary.Initialize(_cache);
return _cache;
}
@@ -39,33 +39,42 @@ namespace PkmnLibSharpTests.Battling
{
var settings = new LibrarySettings(100, 4, 4096);
var species = new SpeciesLibrary(10);
species.Insert("testSpecies", new Species(1, "testSpecies",
new Forme("default", 10f, 10f, 100, new byte[] {0, 1}, 100,
100, 100, 100, 100, 100, new[] {"testAbility", "testAbility2"},
new[] {"testHiddenAbility"}, new LearnableMoves(100), new string[0]), 0.5f, "growthRate",
20, 100, new[]{"testEggGroup"}, new string[0]));
var abilities = new AbilityLibrary(10);
var testAbility1 = new Ability("testAbility1", "", Array.Empty<EffectParameter>());
var testAbility2 = new Ability("testAbility2", "", Array.Empty<EffectParameter>());
var testHiddenAbility = new Ability("testHiddenAbility", "", Array.Empty<EffectParameter>());
abilities.Insert("testAbility1", testAbility1);
abilities.Insert("testAbility2", testAbility2);
abilities.Insert("testHiddenAbility", testHiddenAbility);
species.Insert("testSpecies",
new Species(1, "testSpecies",
new Forme("default", 10f, 10f, 100, new byte[] { 0, 1 }, 100, 100, 100, 100, 100, 100,
new[] { testAbility1, testAbility2 }, new[] { testHiddenAbility }, new LearnableMoves(100),
new string[0]), 0.5f, "growthRate", 20, 100, new[] { "testEggGroup" }, new string[0]));
var moves = new MoveLibrary(10);
moves.Insert("testMove", new MoveData("testMove", 0, MoveCategory.Physical, 100,
100, 20, MoveTarget.Any, 0, 0f, "",
new EffectParameter[0], new string[0]));
moves.Insert("testMove2", new MoveData("testMove2", 0, MoveCategory.Physical, 100,
100, 20, MoveTarget.Any, 0, 0f, "",
new EffectParameter[0], new string[0]));
moves.Insert("testMove",
new MoveData("testMove", 0, MoveCategory.Physical, 100, 100, 20, MoveTarget.Any, 0, 0f, "",
new EffectParameter[0], new string[0]));
moves.Insert("testMove2",
new MoveData("testMove2", 0, MoveCategory.Physical, 100, 100, 20, MoveTarget.Any, 0, 0f, "",
new EffectParameter[0], new string[0]));
var items = new ItemLibrary(10);
items.Insert("testItem", new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.None,
500, "", new EffectParameter[0], new string[] { }, 20));
items.Insert("testItem",
new Item("testItem", ItemCategory.MiscItem, BattleItemCategory.None, 500, "", new EffectParameter[0],
new string[] { }, 20));
var gr = new GrowthRateLibrary(10);
gr.AddGrowthRate("growthRate",
new LookupGrowthRate(
Enumerable.Range(1, 100).Select(x => (uint)x * 100).ToArray()));
gr.AddGrowthRate("growthRate",
new LookupGrowthRate(Enumerable.Range(1, 100).Select(x => (uint)x * 100).ToArray()));
var types = new TypeLibrary(10);
types.RegisterType("normal");
types.RegisterType("fighting");
var natures = new NatureLibrary(10);
natures.LoadNature("testNature", new Nature());
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
return lib;
}
}

View File

@@ -1,3 +1,4 @@
using System.Linq;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
@@ -51,7 +52,9 @@ namespace PkmnLibSharpTests.Library
{
var p = new EffectParameter(10);
var ex = Assert.Throws<NativeException>(() => { p.AsString(); });
Assert.AreEqual("[CreatureLibLibrary] - '[CreatureLib_EffectParameter_AsString] [EffectParameter.hpp:50] Cast effect parameter to string, but was Int'", ex.Message);
Assert.AreEqual(
"[CreatureLibLibrary] - '[CreatureLib_EffectParameter_AsString] [EffectParameter.hpp:53] \"Cast effect parameter to string, but was Int\"'",
ex.Message.Split('\n').First());
p.Dispose();
}
}

View File

@@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
@@ -8,16 +9,20 @@ namespace PkmnLibSharpTests.Library
[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), new string[0]);
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]);
forme.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), new string[0]);
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]);
Assert.AreEqual("foo", forme.Name);
forme.Dispose();
}
@@ -25,8 +30,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetHeight()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
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]);
Assert.AreEqual(1f, forme.Height);
forme.Dispose();
}
@@ -34,8 +41,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetWeight()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
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]);
Assert.AreEqual(2f, forme.Weight);
forme.Dispose();
}
@@ -43,22 +52,26 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetBaseExperience()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
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]);
Assert.AreEqual(100, forme.BaseExperience);
forme.Dispose();
}
[Test]
public void GetTypes()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
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]);
Assert.AreEqual(0, forme.GetPkmnType(0));
forme.Dispose();
forme = new Forme("foo", 1, 2, 100, new byte[] {0, 1}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
forme = new Forme("foo", 1, 2, 100, new byte[] { 0, 1 }, 10, 10, 10, 10, 10, 10, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(0, forme.GetPkmnType(0));
Assert.AreEqual(1, forme.GetPkmnType(1));
forme.Dispose();
@@ -67,8 +80,10 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetStats()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 20, 30, 40, 50, 60, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
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, 20, 30, 40, 50, 60, new[] { ability1 },
new[] { ability2 }, new LearnableMoves(100), new string[0]);
Assert.AreEqual(10, forme.BaseHealth);
Assert.AreEqual(20, forme.BaseAttack);
Assert.AreEqual(30, forme.BaseDefense);
@@ -81,20 +96,23 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetAbilities()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
Assert.AreEqual("foo", forme.Abilities[0]);
forme.Dispose();
}
[Test]
public void GetHiddenAbilities()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
Assert.AreEqual("bar", forme.HiddenAbilities[0]);
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), Array.Empty<string>());
Assert.AreEqual("foo", forme.Abilities[0].Name);
forme.Dispose();
}
[Test]
public void GetHiddenAbilities()
{
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]);
Assert.AreEqual("bar", forme.HiddenAbilities[0].Name);
forme.Dispose();
}
}
}

View File

@@ -17,9 +17,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
lib.Dispose();
}
@@ -32,9 +33,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var s = lib.SpeciesLibrary;
Assert.AreEqual(species, s);
lib.Dispose();
@@ -49,9 +51,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var s = lib.Settings;
Assert.AreEqual(settings, s);
lib.Dispose();
@@ -66,9 +69,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var m = lib.MoveLibrary;
Assert.AreEqual(moves, m);
lib.Dispose();
@@ -83,9 +87,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var i = lib.ItemLibrary;
Assert.AreEqual(items, i);
lib.Dispose();
@@ -100,9 +105,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var g = lib.GrowthRateLibrary;
Assert.AreEqual(gr, g);
lib.Dispose();
@@ -117,9 +123,10 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var t = lib.TypeLibrary;
Assert.AreEqual(types, t);
lib.Dispose();
@@ -134,13 +141,32 @@ namespace PkmnLibSharpTests.Library
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, natures);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var n = lib.NatureLibrary;
Assert.AreEqual(natures, n);
lib.Dispose();
}
[Test]
public void GetAbilityLibrary()
{
var settings = new LibrarySettings(100, 4, 4096);
var species = new SpeciesLibrary(10);
var moves = new MoveLibrary(10);
var items = new ItemLibrary(10);
var gr = new GrowthRateLibrary(10);
var types = new TypeLibrary(10);
var abilities = new AbilityLibrary(10);
var natures = new NatureLibrary(10);
var lib = new PokemonLibrary(settings, species, moves, items, gr, types, abilities, natures);
var a = lib.AbilityLibrary;
Assert.AreEqual(abilities, a);
lib.Dispose();
}
}
}

View File

@@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
@@ -16,21 +17,28 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Insert()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
library.Dispose();
}
[Test]
public void Delete()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
@@ -38,31 +46,34 @@ namespace PkmnLibSharpTests.Library
Assert.AreEqual(0, library.Count);
library.Dispose();
}
[Test]
public void Get()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
var m = library.Get("foobar");
Assert.AreEqual(m.Name, "testSpecies");
Assert.Throws<NativeException>(() =>
{
library.Get("barfoo");
});
Assert.Throws<NativeException>(() => { library.Get("barfoo"); });
library.Dispose();
}
[Test]
public void TryGet()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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]);
var library = new SpeciesLibrary(100);
library.Insert("foobar", species);
Assert.AreEqual(1, library.Count);
@@ -71,6 +82,5 @@ namespace PkmnLibSharpTests.Library
Assert.False(library.TryGet("barfoo", out species));
library.Dispose();
}
}
}

View File

@@ -1,113 +1,147 @@
using System;
using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharpTests.Library
{
public class SpeciesTests
public class SpeciesTests
{
[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), new string[0]);
var species = new Species(0, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
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()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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");
});
Assert.Throws<NativeException>(() => { species.GetForme("non-existing"); });
species.Dispose();
}
[Test]
public void TrGetForme()
public void TryGetForme()
{
var forme = new Forme("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, new LearnableMoves(100), new string[0]);
var species = new Species(10, "testSpecies", forme, 0.5f, "exponential", 100, 80, new[]{"testEggGroup"}, new string[0]);
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();
}
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
@@ -11,9 +11,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="nunit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>