Nature Library, Nature wrapper and tests, cleanup to ensure no duplicate enums are visible outside the library.

This commit is contained in:
2020-05-06 14:40:29 +02:00
parent 8845f33d04
commit 95a2270ca3
78 changed files with 366 additions and 109 deletions

View File

@@ -1,6 +1,7 @@
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.Items;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharpTests.Library

View File

@@ -1,6 +1,7 @@
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.Items;
namespace PkmnLibSharpTests.Library
{

View File

@@ -1,6 +1,7 @@
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.Moves;
namespace PkmnLibSharpTests.Library
{
@@ -9,7 +10,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void ConstructDestruct()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
move.Dispose();
}
@@ -17,7 +18,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetName()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual("foobar", move.Name);
move.Dispose();
@@ -26,7 +27,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetType()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(0, move.Type);
move.Dispose();
@@ -35,7 +36,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetCategory()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(MoveCategory.Physical, move.Category);
move.Dispose();
@@ -44,7 +45,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetBasePower()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(60, move.BasePower);
move.Dispose();
@@ -53,7 +54,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetAccuracy()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(100, move.Accuracy);
move.Dispose();
@@ -62,7 +63,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetBaseUsages()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(20, move.BaseUsages);
move.Dispose();
@@ -71,16 +72,16 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetTarget()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(AttackTarget.Adjacent, move.Target);
Assert.AreEqual(MoveTarget.Adjacent, move.Target);
move.Dispose();
}
[Test]
public void GetPriority()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(1, move.Priority);
move.Dispose();
@@ -89,7 +90,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetEffectChance()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0.5f, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(0.5f, move.SecondaryEffectChance);
move.Dispose();
@@ -98,7 +99,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void GetEffectChanceName()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
Assert.AreEqual("test", move.SecondaryEffectName);
move.Dispose();
@@ -107,11 +108,11 @@ namespace PkmnLibSharpTests.Library
[Test]
public void HasSecondaryEffect()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
Assert.True(move.HasSecondaryEffect);
move.Dispose();
move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0.5f, "", new EffectParameter[0], new string[0]);
Assert.False(move.HasSecondaryEffect);
move.Dispose();
@@ -121,7 +122,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void HasFlag()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, MoveTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new []{"flag1"});
Assert.True(move.HasFlag("flag1"));
Assert.False(move.HasFlag("flag2"));

View File

@@ -3,6 +3,7 @@ using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp;
using PkmnLibSharp.Library;
using PkmnLibSharp.Library.Moves;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharpTests.Library
@@ -19,7 +20,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Insert()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
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);
@@ -30,7 +31,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Delete()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
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);
@@ -43,7 +44,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void Get()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
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);
@@ -60,7 +61,7 @@ namespace PkmnLibSharpTests.Library
[Test]
public void TryGet()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
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);

View File

@@ -0,0 +1,43 @@
using NUnit.Framework;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class NatureLibraryTests
{
[Test]
public void ConstructDestruct()
{
var nl = new NatureLibrary(0);
nl.Dispose();
}
[Test]
public void LoadNature()
{
var nl = new NatureLibrary(1);
nl.LoadNature("foo", new Nature());
nl.Dispose();
}
[Test]
public void GetNature()
{
var nl = new NatureLibrary(1);
nl.LoadNature("foo", new Nature(Statistic.SpecialAttack, Statistic.SpecialDefense));
Assert.AreEqual(Statistic.SpecialAttack, nl.GetNature("foo").IncreasedStat);
nl.Dispose();
}
[Test]
public void GetNatureName()
{
var nl = new NatureLibrary(1);
nl.LoadNature("foo", new Nature(Statistic.SpecialAttack, Statistic.SpecialDefense));
var nature = nl.GetNature("foo");
Assert.AreEqual("foo", nl.GetNatureName(nature));
nl.Dispose();
}
}
}

View File

@@ -0,0 +1,53 @@
using NUnit.Framework;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class NatureTests
{
[Test]
public void ConstructDestruct()
{
var nature = new Nature(Statistic.Attack, Statistic.Defense);
nature.Dispose();
}
[Test]
public void GetIncreasedStat()
{
var nature = new Nature(Statistic.Attack, Statistic.Defense);
Assert.AreEqual(Statistic.Attack, nature.IncreasedStat);
nature.Dispose();
}
[Test]
public void GetIncreasedModifier()
{
var nature = new Nature(Statistic.Attack, Statistic.Defense);
Assert.AreEqual(1.1f, nature.IncreasedModifier);
nature.Dispose();
}
[Test]
public void GetDecreasedStat()
{
var nature = new Nature(Statistic.Attack, Statistic.Defense);
Assert.AreEqual(Statistic.Defense, nature.DecreasedStat);
nature.Dispose();
}
[Test]
public void GetDecreasedModifier()
{
var nature = new Nature(Statistic.Attack, Statistic.Defense);
Assert.AreEqual(0.9f, nature.DecreasedModifier);
nature.Dispose();
}
[Test]
public void GetStatModifier()
{
var nature = new Nature(Statistic.Attack, Statistic.Defense);
Assert.AreEqual(0.9f, nature.GetStatModifier(Statistic.Defense));
Assert.AreEqual(1f, nature.GetStatModifier(Statistic.SpecialAttack));
nature.Dispose();
}
}
}