diff --git a/NWNX.NET.Tests/src/main/Tests/NWNXVMTests.cs b/NWNX.NET.Tests/src/main/Tests/NWNXVMTests.cs new file mode 100644 index 0000000..1cb7117 --- /dev/null +++ b/NWNX.NET.Tests/src/main/Tests/NWNXVMTests.cs @@ -0,0 +1,26 @@ +using NUnit.Framework; + +namespace NWNX.NET.Tests +{ + [TestFixture(Category = "NWNX VM Tests")] + public sealed class NWNXVMTests + { + [Test] + [TestCase("NWNX_Core", 1)] + [TestCase("NWNX_DotNET", 1)] + [TestCase("NWNX_SWIG_DotNET", 1)] + [TestCase("NWNX_MissingPlugin", 0)] + [TestCase("", 0)] + [TestCase(null, 0, Ignore = "NWNX throws a std::logic_error")] + public void PluginExistsTest(string plugin, int expectedResult) + { + NWNXAPI.NWNXSetFunction("NWNX_Core", "PluginExists"); + NWNXAPI.NWNXPushString(plugin); + NWNXAPI.NWNXCallFunction(); + + int result = NWNXAPI.NWNXPopInt(); + + Assert.That(result, Is.EqualTo(expectedResult)); + } + } +} diff --git a/NWNX.NET/src/main/API/NWNXAPI.VM.NWNX.cs b/NWNX.NET/src/main/API/NWNXAPI.VM.NWNX.cs index d5f1525..1f71db8 100644 --- a/NWNX.NET/src/main/API/NWNXAPI.VM.NWNX.cs +++ b/NWNX.NET/src/main/API/NWNXAPI.VM.NWNX.cs @@ -15,7 +15,7 @@ public static partial class NWNXAPI /// The name of the function to call. [LibraryImport("NWNX_DotNET", EntryPoint = "NWNXSetFunction")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] - public static partial void NWNXSetFunction([MarshalUsing(typeof(Utf16StringMarshaller))] string plugin, [MarshalUsing(typeof(Utf16StringMarshaller))] string function); + public static partial void NWNXSetFunction([MarshalUsing(typeof(Utf8StringMarshaller))] string plugin, [MarshalUsing(typeof(Utf8StringMarshaller))] string function); /// /// NWNX VM Function. Push an integer to the current argument stack.