52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System;
|
|
using NUnit.Framework;
|
|
using PkmnLibSharp.StaticData;
|
|
using PkmnLibSharp.StaticData.Libraries;
|
|
|
|
namespace PkmnLibRSharpTests.StaticData.Libraries
|
|
{
|
|
public class ItemLibraryTests
|
|
{
|
|
[Test]
|
|
public void Create()
|
|
{
|
|
using var lib = new ItemLibrary(0);
|
|
Assert.AreEqual(0, lib.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateAndAdd()
|
|
{
|
|
using var lib = new ItemLibrary(1);
|
|
Assert.AreEqual(0, lib.Count);
|
|
using var item = new Item("testItem", ItemCategory.Mail, BattleItemCategory.None, 100, Array.Empty<string>());
|
|
lib.Add("foobar", item);
|
|
Assert.AreEqual(1, lib.Count);
|
|
Assert.AreEqual("testItem", lib["foobar"].Name);
|
|
}
|
|
|
|
[Test]
|
|
public void CreateAddIterate()
|
|
{
|
|
using var lib = new ItemLibrary(10);
|
|
Assert.AreEqual(0, lib.Count);
|
|
for (ushort i = 0; i < 10; i++)
|
|
{
|
|
using var item = new Item(i.ToString(), ItemCategory.Mail, BattleItemCategory.None, 100,
|
|
Array.Empty<string>());
|
|
lib.Add(i + "_key", item);
|
|
}
|
|
|
|
Assert.AreEqual(10, lib.Count);
|
|
var index = 0;
|
|
foreach (var kv in lib)
|
|
{
|
|
Assert.AreEqual(kv.Key, index + "_key");
|
|
Assert.AreEqual(kv.Value.Name, index.ToString());
|
|
index++;
|
|
}
|
|
|
|
Assert.AreEqual(10, index);
|
|
}
|
|
}
|
|
} |