PorygonSharp/PorygonSharpTests/EnumUserdataTest.cs

52 lines
1.5 KiB
C#
Raw Normal View History

using System;
using NUnit.Framework;
using PorygonSharp;
using PorygonSharp.UserData;
namespace PorygonSharpTests
{
public class EnumUserdataTest
{
private enum testEnum
{
One, Two, Three, Foo, Bar
}
[Test]
public void AbleToAccessStaticEnumVariable()
{
2019-09-19 13:44:39 +00:00
StaticScope.RegisterStaticEnum("testEnum", typeof(testEnum));
using (var script = new Script(@"
return type(testEnum)
"))
{
var diags = script.Diagnostics.GetDiagnostics();
foreach (var diag in diags)
{
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
}
var result = script.Evaluate();
Assert.AreEqual("userdata", result.EvaluateString());
}
}
[Test]
public void AbleToUseStaticEnumVariable()
{
2019-09-19 13:44:39 +00:00
StaticScope.RegisterStaticEnum("testEnum", typeof(testEnum));
using (var script = new Script(@"
return testEnum.Three + 2
"))
{
var diags = script.Diagnostics.GetDiagnostics();
foreach (var diag in diags)
{
throw new Exception(script.Diagnostics.GetFullDiagnosticMessage(diag));
}
var result = script.Evaluate();
Assert.AreEqual(4, result.EvaluateInteger());
}
}
}
}