Tests for MoveLibrary

This commit is contained in:
Deukhoofd 2020-05-04 17:27:30 +02:00
parent 0a5a78bc13
commit 0a22959e31
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,74 @@
using System;
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class MoveLibraryTests
{
[Test]
public void ConstructDestruct()
{
var item = MoveLibrary.Create(100);
item.Dispose();
}
[Test]
public void Insert()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
var library = MoveLibrary.Create(100);
library.Insert("foobar", move);
Assert.AreEqual(1, library.Count);
library.Dispose();
}
[Test]
public void Delete()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
var library = MoveLibrary.Create(100);
library.Insert("foobar", move);
Assert.AreEqual(1, library.Count);
library.Delete("foobar");
Assert.AreEqual(0, library.Count);
library.Dispose();
}
[Test]
public void Get()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
var library = MoveLibrary.Create(100);
library.Insert("foobar", move);
Assert.AreEqual(1, library.Count);
var m = library.Get("foobar");
Assert.AreEqual(m.Name, "foobar");
Assert.Throws<NativeException>(() =>
{
library.Get("barfoo");
});
library.Dispose();
}
[Test]
public void TryGet()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
var library = MoveLibrary.Create(100);
library.Insert("foobar", move);
Assert.AreEqual(1, library.Count);
Assert.True(library.TryGet("foobar", out move));
Assert.AreEqual(move.Name, "foobar");
Assert.False(library.TryGet("barfoo", out move));
library.Dispose();
}
}
}