2020-05-05 19:40:04 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
using PkmnLibSharp.Library;
|
2020-05-06 12:40:29 +00:00
|
|
|
using PkmnLibSharp.Library.Items;
|
2020-05-05 19:40:04 +00:00
|
|
|
using PkmnLibSharp.Utilities;
|
|
|
|
|
|
|
|
namespace PkmnLibSharpTests.Library
|
|
|
|
{
|
|
|
|
public class ItemLibraryTests
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void ConstructDestruct()
|
|
|
|
{
|
|
|
|
var item = new ItemLibrary(100);
|
|
|
|
item.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Insert()
|
|
|
|
{
|
|
|
|
var item = Item.Create("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
|
|
|
|
new[] {"testFlag"}, 50);
|
|
|
|
var library = new ItemLibrary(100);
|
|
|
|
library.Insert("foobar", item);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
library.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Delete()
|
|
|
|
{
|
|
|
|
var item = Item.Create("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
|
|
|
|
new[] {"testFlag"}, 50);
|
|
|
|
var library = new ItemLibrary(100);
|
|
|
|
library.Insert("foobar", item);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
library.Delete("foobar");
|
|
|
|
Assert.AreEqual(0, library.Count);
|
|
|
|
library.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Get()
|
|
|
|
{
|
|
|
|
var item = Item.Create("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
|
|
|
|
new[] {"testFlag"}, 50);
|
|
|
|
var library = new ItemLibrary(100);
|
|
|
|
library.Insert("foobar", item);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
var m = library.Get("foobar");
|
|
|
|
Assert.AreEqual(m.Name, "testItem");
|
|
|
|
Assert.Throws<NativeException>(() =>
|
|
|
|
{
|
|
|
|
library.Get("barfoo");
|
|
|
|
});
|
|
|
|
library.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TryGet()
|
|
|
|
{
|
|
|
|
var item = Item.Create("testItem", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
|
|
|
|
new[] {"testFlag"}, 50);
|
|
|
|
var library = new ItemLibrary(100);
|
|
|
|
library.Insert("foobar", item);
|
|
|
|
Assert.AreEqual(1, library.Count);
|
|
|
|
Assert.True(library.TryGet("foobar", out item));
|
|
|
|
Assert.AreEqual(item.Name, "testItem");
|
|
|
|
Assert.False(library.TryGet("barfoo", out item));
|
|
|
|
library.Dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|