A load more work on FFI
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
130
PkmnLibRSharpTests/DynamicData/PokemonTests.cs
Normal file
130
PkmnLibRSharpTests/DynamicData/PokemonTests.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.DynamicData;
|
||||
using PkmnLibSharp.DynamicData.Libraries;
|
||||
using PkmnLibSharp.StaticData;
|
||||
using PkmnLibSharp.StaticData.Libraries;
|
||||
|
||||
namespace PkmnLibRSharpTests.DynamicData
|
||||
{
|
||||
public class PokemonTests
|
||||
{
|
||||
[Test]
|
||||
public void Pokemon_GetLibrary()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(library, pokemon.Library);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetSpecies()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"], pokemon.Species);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetForm()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"].DefaultForm, pokemon.Form);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetDisplaySpecies()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"], pokemon.Species);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetDisplayForm()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(library.StaticData.SpeciesLibrary["testSpecies"].DefaultForm, pokemon.Form);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetLevel()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(100, pokemon.Level);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetExperience()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).Build();
|
||||
Assert.AreEqual(library.StaticData.GrowthRateLibrary.CalculateExperience("testGrowthrate", 100),
|
||||
pokemon.Experience);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetUniqueIdentifier()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).WithIdentifier(1000).Build();
|
||||
Assert.AreEqual(1000, pokemon.UniqueIdentifier);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetGender()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).WithGender(Gender.Male).Build();
|
||||
Assert.AreEqual(Gender.Male, pokemon.Gender);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Pokemon_GetColoring()
|
||||
{
|
||||
using var library = GetLibrary();
|
||||
using var pokemon = new PokemonBuilder(library, "testSpecies", 100).ForceShiny(true).Build();
|
||||
Assert.AreEqual(1, pokemon.Coloring);
|
||||
}
|
||||
|
||||
private static DynamicLibrary GetLibrary()
|
||||
{
|
||||
using var settings = new LibrarySettings(100, 4096);
|
||||
using var speciesLibrary = new SpeciesLibrary(0);
|
||||
FillSpeciesLibrary(speciesLibrary);
|
||||
using var moves = new MoveLibrary(0);
|
||||
using var items = new ItemLibrary(0);
|
||||
using var growthRates = new GrowthRateLibrary(0);
|
||||
using var gr = CommonGrowthRates.Erratic(100);
|
||||
growthRates.AddGrowthRate("testGrowthrate", gr);
|
||||
using var types = new TypeLibrary(0);
|
||||
using var natures = new NatureLibrary(0);
|
||||
natures.LoadNature("testNature", Nature.NeutralNature());
|
||||
using var abilities = new AbilityLibrary(0);
|
||||
using var library = new PkmnLibSharp.StaticData.Libraries.StaticData(settings, speciesLibrary, moves, items,
|
||||
growthRates, types, natures, abilities);
|
||||
|
||||
using var statCalc = new Gen7BattleStatCalculator();
|
||||
using var damageLib = new Gen7DamageLibrary(false);
|
||||
using var miscLib = new Gen7MiscLibrary();
|
||||
using var scriptResolver = new WasmScriptResolver();
|
||||
|
||||
return new DynamicLibrary(library, statCalc, damageLib, miscLib, scriptResolver);
|
||||
}
|
||||
|
||||
private static void FillSpeciesLibrary(SpeciesLibrary speciesLibrary)
|
||||
{
|
||||
using var stats = new StaticStatisticSet<short>(5, 10, 30, 20, 2, 0);
|
||||
using var moves = new LearnableMoves();
|
||||
using var form = new Form("foobar", 0.2f, 5.8f, 300, new TypeIdentifier[] { new(1), new(2) }, stats,
|
||||
new[] { "foo", "bar" }, new[] { "set" }, moves, Array.Empty<string>());
|
||||
using var species =
|
||||
new Species(10, "testSpecies", 0.2f, "testGrowthrate", 120, form, Array.Empty<string>());
|
||||
speciesLibrary.Add(species.Name, species);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user