Type Library wrapper and tests

This commit is contained in:
2020-05-06 13:32:43 +02:00
parent cc66729529
commit 8845f33d04
3 changed files with 131 additions and 1 deletions

View File

@@ -0,0 +1,70 @@
using System;
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();
}
}
}