using PkmnLib.Dynamic.Libraries.DataLoaders;
using PkmnLib.Dynamic.Plugins;

namespace PkmnLib.Tests.Dataloader;

public class TypeDataloaderTests
{
    [Test]
    public async Task TestPrimaryTypesFile()
    {
        IResourceProvider plugin = new Plugin.Gen7.Gen7Plugin();
        var result = plugin.GetResource(ResourceFileType.Types)!;
        await using var file = result.Open();
        var library = TypeDataLoader.LoadTypeLibrary(file);
        await Assert.That(library).IsNotNull();

        var fire = library.TryGetTypeIdentifier("Fire", out var fireId);
        await Assert.That(fire).IsTrue();
        var grass = library.TryGetTypeIdentifier("Grass", out var grassId);
        await Assert.That(grass).IsTrue();

        var fireEffectiveness = library.GetSingleEffectiveness(fireId, grassId);
        await Assert.That(fireEffectiveness).IsEqualTo(2.0f);
    }
}