Added tests for Item wrapper

This commit is contained in:
Deukhoofd 2020-05-05 20:46:17 +02:00
parent 6c0d320656
commit 6491360dbe
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 66 additions and 1 deletions

View File

@ -20,7 +20,6 @@ namespace PkmnLibSharp.Library
public string Name => _name ??= CreatureSpecies.GetName(Ptr).PtrString();
public string GrowthRate => _growthRate ??= CreatureSpecies.GetGrowthRate(Ptr).PtrString();
public bool HasForme(string s)
{
return CreatureSpecies.HasVariant(Ptr, s.ToPtr()) == MarshalHelper.True;

View File

@ -0,0 +1,66 @@
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class ItemTests
{
[Test]
public void ConstructDestruct()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
item.Dispose();
}
[Test]
public void GetName()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
Assert.AreEqual("foobar", item.Name);
item.Dispose();
}
[Test]
public void GetCategory()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
Assert.AreEqual(ItemCategory.MiscItem, item.Category);
item.Dispose();
}
[Test]
public void GetBattleCategory()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
Assert.AreEqual(BattleItemCategory.Healing, item.BattleCategory);
item.Dispose();
}
[Test]
public void GetPrice()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
Assert.AreEqual(1000, item.Price);
item.Dispose();
}
[Test]
public void HasFlag()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
Assert.True(item.HasFlag("testFlag"));
Assert.False(item.HasFlag("non-existing"));
item.Dispose();
}
[Test]
public void GetFlingPower()
{
var item = Item.Create("foobar", ItemCategory.MiscItem, BattleItemCategory.Healing, 1000,
new[] {"testFlag"}, 50);
Assert.AreEqual(50, item.FlingPower);
item.Dispose();
}
}
}