Lots of work
This commit is contained in:
60
PkmnLibSharpTests/Library/EffectParameterTests.cs
Normal file
60
PkmnLibSharpTests/Library/EffectParameterTests.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Pkmnlib;
|
||||
using PkmnLibSharp;
|
||||
using PkmnLibSharp.Library;
|
||||
|
||||
namespace PkmnLibSharpTests.Library
|
||||
{
|
||||
public class EffectParameterTests
|
||||
{
|
||||
[Test]
|
||||
public void CreateInt([Range(-10000000, 10000000, 1000000)] long value)
|
||||
{
|
||||
var p = new EffectParameter(value);
|
||||
Assert.AreEqual(EffectParameterType.Int, p.ParameterType);
|
||||
Assert.AreEqual(value, p.AsInt());
|
||||
p.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateBool()
|
||||
{
|
||||
var p = new EffectParameter(true);
|
||||
Assert.AreEqual(EffectParameterType.Bool, p.ParameterType);
|
||||
Assert.AreEqual(true, p.AsBool());
|
||||
p.Dispose();
|
||||
p = new EffectParameter(false);
|
||||
Assert.AreEqual(EffectParameterType.Bool, p.ParameterType);
|
||||
Assert.AreEqual(false, p.AsBool());
|
||||
p.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateFloat([Range(-5, 5, 0.25f)] float value)
|
||||
{
|
||||
var p = new EffectParameter(value);
|
||||
Assert.AreEqual(EffectParameterType.Float, p.ParameterType);
|
||||
Assert.AreEqual(value, p.AsFloat());
|
||||
p.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateString()
|
||||
{
|
||||
var p = new EffectParameter("foobar");
|
||||
Assert.AreEqual(EffectParameterType.String, p.ParameterType);
|
||||
Assert.AreEqual("foobar", p.AsString());
|
||||
p.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThrowOnWrongType()
|
||||
{
|
||||
var p = new EffectParameter(10);
|
||||
var ex = Assert.Throws<NativeException>(() => { p.AsString(); });
|
||||
Assert.AreEqual("[CreatureLib] - 'Cast effect parameter to string, but was Int'", ex.Message);
|
||||
p.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Library;
|
||||
|
||||
|
||||
namespace PkmnLibSharpTests
|
||||
namespace PkmnLibSharpTests.Library
|
||||
{
|
||||
public class FormeTests
|
||||
{
|
||||
@@ -10,7 +9,7 @@ namespace PkmnLibSharpTests
|
||||
public void ConstructDestruct()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
forme.Dispose();
|
||||
}
|
||||
|
||||
@@ -18,7 +17,7 @@ namespace PkmnLibSharpTests
|
||||
public void GetName()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual("foo", forme.Name);
|
||||
forme.Dispose();
|
||||
}
|
||||
@@ -27,7 +26,7 @@ namespace PkmnLibSharpTests
|
||||
public void GetHeight()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual(1f, forme.Height);
|
||||
forme.Dispose();
|
||||
}
|
||||
@@ -36,7 +35,7 @@ namespace PkmnLibSharpTests
|
||||
public void GetWeight()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual(2f, forme.Weight);
|
||||
forme.Dispose();
|
||||
}
|
||||
@@ -45,7 +44,7 @@ namespace PkmnLibSharpTests
|
||||
public void GetBaseExperience()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual(100, forme.BaseExperience);
|
||||
forme.Dispose();
|
||||
}
|
||||
@@ -54,16 +53,48 @@ namespace PkmnLibSharpTests
|
||||
public void GetTypes()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual(0, forme.GetPkmnType(0));
|
||||
forme.Dispose();
|
||||
|
||||
forme = Forme.Create("foo", 1, 2, 100, new byte[] {0, 1}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"});
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual(0, forme.GetPkmnType(0));
|
||||
Assert.AreEqual(1, forme.GetPkmnType(1));
|
||||
forme.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetStats()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 20, 30, 40, 50, 60, new[] {"foo"},
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual(10, forme.BaseHealth);
|
||||
Assert.AreEqual(20, forme.BaseAttack);
|
||||
Assert.AreEqual(30, forme.BaseDefense);
|
||||
Assert.AreEqual(40, forme.BaseSpecialAttack);
|
||||
Assert.AreEqual(50, forme.BaseSpecialDefense);
|
||||
Assert.AreEqual(60, forme.BaseSpeed);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAbilities()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual("foo", forme.Abilities[0]);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetHiddenAbilities()
|
||||
{
|
||||
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
|
||||
new[] {"bar"}, LearnableMoves.Create(100));
|
||||
Assert.AreEqual("bar", forme.HiddenAbilities[0]);
|
||||
forme.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
132
PkmnLibSharpTests/Library/MoveDataTests.cs
Normal file
132
PkmnLibSharpTests/Library/MoveDataTests.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using NUnit.Framework;
|
||||
using Pkmnlib;
|
||||
using PkmnLibSharp.Library;
|
||||
|
||||
namespace PkmnLibSharpTests.Library
|
||||
{
|
||||
public class MoveDataTests
|
||||
{
|
||||
[Test]
|
||||
public void ConstructDestruct()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetName()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual("foobar", move.Name);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetType()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(0, move.Type);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetCategory()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(MoveCategory.Physical, move.Category);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetBasePower()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(60, move.BasePower);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAccuracy()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(100, move.Accuracy);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetBaseUsages()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(20, move.BaseUsages);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTarget()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(AttackTarget.Adjacent, move.Target);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetPriority()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(1, move.Priority);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEffectChance()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0.5f, "", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual(0.5f, move.SecondaryEffectChance);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEffectChanceName()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0.5f, "test", new EffectParameter[0], new string[0]);
|
||||
Assert.AreEqual("test", move.SecondaryEffectName);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HasSecondaryEffect()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.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,
|
||||
0.5f, "", new EffectParameter[0], new string[0]);
|
||||
Assert.False(move.HasSecondaryEffect);
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void HasFlag()
|
||||
{
|
||||
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
|
||||
0.5f, "test", new EffectParameter[0], new []{"flag1"});
|
||||
Assert.True(move.HasFlag("flag1"));
|
||||
Assert.False(move.HasFlag("flag2"));
|
||||
move.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user