Exemplo n.º 1
0
        public void registerObjectTest()
        {
            CSLua.LuaState L          = new CSLua.LuaState();
            Multiplier     multiplier = new Multiplier("MyMult");

            L.registerObject("testObject", multiplier);

            CSLua.MultiValue result = L.dostring("return testObject:multiply(7, 13)");
            Assert.AreEqual(91.0, result[0]);

            result = L.dostring("return testObject:multiply(1, 1)");
            Assert.AreEqual(1.0, result[0]);

            result = L.dostring("return testObject:multiply(100001, 7)");
            Assert.AreEqual(700007.0, result[0]);
        }
Exemplo n.º 2
0
        public void unRegisterObjectTest()
        {
            // unregisterObject is not yet implemented.

            CSLua.LuaState L          = new CSLua.LuaState();
            Multiplier     multiplier = new Multiplier("MyMult");

            L.registerObject("testObject", multiplier);

            {
                var result = L.dostring("return testObject:multiply(1, 1)");
                Assert.AreEqual(1.0, result[0]);
            }

            // This is not yet implemented
            L.unregisterObject(multiplier);

            {
                var result = L.dostring("return testObject:multiply(1, 1)");
                Assert.AreEqual(null, result[0]);
            }
        }