PkmnLibSharp/PkmnLibSharpTests/Library/EffectParameterTests.cs

58 lines
1.9 KiB
C#

using NUnit.Framework;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
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("[CreatureLibLibrary] - '[CreatureLib_EffectParameter_AsString] [EffectParameter.hpp:52] Cast effect parameter to string, but was Int'", ex.Message);
p.Dispose();
}
}
}