using NUnit.Framework;
using PkmnLibSharp.Library;

namespace PkmnLibSharpTests.Library
{
    public class TypeLibraryTests
    {
        [Test]
        public void ConstructDestruct()
        {
            var tl = new TypeLibrary(0);
            tl.Dispose();
        }
        [Test]
        public void RegisterType()
        {
            var tl = new TypeLibrary(0);
            tl.RegisterType("testType1");
            tl.Dispose();
        }
        [Test]
        public void GetTypeId()
        {
            var tl = new TypeLibrary(0);
            tl.RegisterType("testType1");
            var id = tl.GetTypeId("testType1");
            Assert.AreEqual(0, id);
            tl.RegisterType("testType2");
            id = tl.GetTypeId("testType2");
            Assert.AreEqual(1, id);
            tl.Dispose();
        }
        [Test]
        public void SetEffectiveness()
        {
            var tl = new TypeLibrary(0);
            tl.RegisterType("testType1");
            tl.RegisterType("testType2");
            tl.SetEffectiveness(0, 1, 0.5f);
            tl.SetEffectiveness(1, 0, 2f);
            tl.Dispose();
        }
        [Test]
        public void GetSingleEffectiveness()
        {
            var tl = new TypeLibrary(0);
            tl.RegisterType("testType1");
            tl.RegisterType("testType2");
            tl.SetEffectiveness(0, 1, 0.5f);
            tl.SetEffectiveness(1, 0, 2f);
            Assert.AreEqual(0.5f, tl.GetSingleEffectiveness(0, 1));
            Assert.AreEqual(2f, tl.GetSingleEffectiveness(1, 0));
            tl.Dispose();
        }
        [Test]
        public void GetEffectiveness()
        {
            var tl = new TypeLibrary(0);
            tl.RegisterType("testType1");
            tl.RegisterType("testType2");
            tl.SetEffectiveness(0, 1, 0.5f);
            tl.SetEffectiveness(0, 0, 0.5f);
            tl.SetEffectiveness(1, 0, 2f);
            Assert.AreEqual(0.25f, tl.GetEffectiveness(0, new byte[] {0, 1}));
            tl.Dispose();
        }

    }
}