PkmnLibSharp/PkmnLibSharpTests/Library/EffectParameterTests.cs

58 lines
1.9 KiB
C#
Raw Normal View History

2020-05-02 20:58:08 +00:00
using NUnit.Framework;
using PkmnLibSharp.Library;
2020-05-04 15:54:34 +00:00
using PkmnLibSharp.Utilities;
2020-05-02 20:58:08 +00:00
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:54] Cast effect parameter to string, but was Int'", ex.Message);
2020-05-02 20:58:08 +00:00
p.Dispose();
}
}
}