2022-10-01 13:39:33 +00:00
|
|
|
using System;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using PkmnLibSharp.StaticData;
|
|
|
|
using PkmnLibSharp.StaticData.Libraries;
|
|
|
|
|
|
|
|
namespace PkmnLibRSharpTests.StaticData.Libraries
|
|
|
|
{
|
|
|
|
public class ItemLibraryTests
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void Create()
|
|
|
|
{
|
2023-06-25 14:30:12 +00:00
|
|
|
var lib = ItemLibrary.Create(0);
|
2022-10-01 13:39:33 +00:00
|
|
|
Assert.AreEqual(0, lib.Count);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void CreateAndAdd()
|
|
|
|
{
|
2023-06-25 14:30:12 +00:00
|
|
|
var lib = ItemLibrary.Create(1);
|
2022-10-01 13:39:33 +00:00
|
|
|
Assert.AreEqual(0, lib.Count);
|
2023-06-25 14:30:12 +00:00
|
|
|
var item = Item.Create("testItem", ItemCategory.Mail, BattleItemCategory.None, 100, Array.Empty<string>());
|
2022-10-01 13:39:33 +00:00
|
|
|
lib.Add("foobar", item);
|
|
|
|
Assert.AreEqual(1, lib.Count);
|
|
|
|
Assert.AreEqual("testItem", lib["foobar"].Name);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void CreateAddIterate()
|
|
|
|
{
|
2023-06-25 14:30:12 +00:00
|
|
|
var lib = ItemLibrary.Create(10);
|
2022-10-01 13:39:33 +00:00
|
|
|
Assert.AreEqual(0, lib.Count);
|
|
|
|
for (ushort i = 0; i < 10; i++)
|
|
|
|
{
|
2023-06-25 14:30:12 +00:00
|
|
|
var item = Item.Create(i.ToString(), ItemCategory.Mail, BattleItemCategory.None, 100,
|
2022-10-01 13:39:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|