PkmnLibSharp/PkmnLibSharpTests/Library/MoveLibraryTests.cs

73 lines
2.5 KiB
C#

using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.Moves;
using PkmnLibSharp.Utilities;
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, MoveTarget.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, MoveTarget.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, MoveTarget.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, MoveTarget.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();
}
}
}