Esempio n. 1
0
        public void TestXMove()
        {
            LuaState L = null;
            using (L = new LuaState())
            {
                L.PushString("#1 Line 1");
                L.PushString("#1 Line 2");
                L.PushString("#1 Line 3");
                Assert.Equal(3, L.GetTop());

                using (LuaState L2 = new LuaState())
                {
                    L2.PushString("#2 Line 1");
                    L2.PushString("#2 Line 2");
                    L2.PushString("#2 Line 3");
                    Assert.Equal(3, L2.GetTop());

                    Assert.Same(L, L.XMove(L2, 2));

                    Assert.Equal(1, L.GetTop());
                    Assert.Equal(5, L2.GetTop());

                    Assert.Equal("#1 Line 1", L.ToString(1));
                    Assert.Equal(null, L.ToString(2));

                    Assert.Equal("#2 Line 1", L2.ToString(1));
                    Assert.Equal("#2 Line 2", L2.ToString(2));
                    Assert.Equal("#2 Line 3", L2.ToString(3));
                    Assert.Equal("#1 Line 2", L2.ToString(4));
                    Assert.Equal("#1 Line 3", L2.ToString(5));

                }

                Assert.Throws<ArgumentNullException>(() => L.XMove(null, 1));

                var mockLs = new Mock<ILuaState>();
                Assert.Throws<InvalidOperationException>(() => L.XMove(mockLs.Object, 1));

            }
        }