using PkmnLib.Dynamic.Libraries.DataLoaders; using PkmnLib.Dynamic.Plugins; using PkmnLib.Dynamic.ScriptHandling.Registry; using PkmnLib.Static.Libraries; namespace PkmnLib.Tests.Dataloader; public class SpeciesDataloaderTests { [Test] public async Task TestPrimarySpeciesFile() { IResourceProvider plugin = new Plugin.Gen7.Gen7Plugin(); var result = plugin.GetResource(ResourceFileType.Species)!; await using var file = result.Open(); var typeLibrary = new TypeLibrary(); typeLibrary.RegisterType("Normal"); typeLibrary.RegisterType("Fire"); typeLibrary.RegisterType("Water"); typeLibrary.RegisterType("Electric"); typeLibrary.RegisterType("Grass"); typeLibrary.RegisterType("Ice"); typeLibrary.RegisterType("Fighting"); typeLibrary.RegisterType("Poison"); typeLibrary.RegisterType("Ground"); typeLibrary.RegisterType("Flying"); typeLibrary.RegisterType("Psychic"); typeLibrary.RegisterType("Bug"); typeLibrary.RegisterType("Rock"); typeLibrary.RegisterType("Ghost"); typeLibrary.RegisterType("Dragon"); typeLibrary.RegisterType("Dark"); typeLibrary.RegisterType("Steel"); typeLibrary.RegisterType("Fairy"); var library = SpeciesDataLoader.LoadSpecies(file, typeLibrary); await Assert.That(library).IsNotNull(); } [Test] public async Task TestPrimarySpeciesFileFormInheritance() { IResourceProvider plugin = new Plugin.Gen7.Gen7Plugin(); var result = plugin.GetResource(ResourceFileType.Species)!; await using var file = result.Open(); var typeLibrary = new TypeLibrary(); typeLibrary.RegisterType("Normal"); typeLibrary.RegisterType("Fire"); typeLibrary.RegisterType("Water"); typeLibrary.RegisterType("Electric"); typeLibrary.RegisterType("Grass"); typeLibrary.RegisterType("Ice"); typeLibrary.RegisterType("Fighting"); typeLibrary.RegisterType("Poison"); typeLibrary.RegisterType("Ground"); typeLibrary.RegisterType("Flying"); typeLibrary.RegisterType("Psychic"); typeLibrary.RegisterType("Bug"); typeLibrary.RegisterType("Rock"); typeLibrary.RegisterType("Ghost"); typeLibrary.RegisterType("Dragon"); typeLibrary.RegisterType("Dark"); typeLibrary.RegisterType("Steel"); typeLibrary.RegisterType("Fairy"); var library = SpeciesDataLoader.LoadSpecies(file, typeLibrary); await Assert.That(library).IsNotNull(); await Assert.That(library.TryGet("arceus", out var species)).IsTrue(); await Assert.That(species).IsNotNull(); await Assert.That(species!.TryGetForm("arceus_fighting", out var form)).IsTrue(); await Assert.That(form).IsNotNull(); await Assert.That(form!.Types).HasCount().EqualTo(1); await Assert.That(form.Types[0].Name).IsEqualTo("fighting"); await Assert.That(form.Flags).IsEqualTo(species.GetDefaultForm().Flags); await Assert.That(form.BaseStats).IsEqualTo(species.GetDefaultForm().BaseStats); } }