Beispiel #1
0
        /* we should allocate object on a separate stack */
        private WeakReference RegisterDummyDelegate(string name)
        {
            Dummy         dummy     = new Dummy();
            WeakReference reference = new WeakReference(new CommandAction <string[]>(dummy.Execute));

            Lunar.RegisterCommand(name, dummy.Execute);

            return(reference);
        }
 internal static void Break()
 {
     Debug.Break();
     Lunar.RegisterCommand("continue", delegate()
     {
         CRegistery.Unregister("continue");
         EditorApplication.ExecuteMenuItem("Edit/Pause");
     });
 }
Beispiel #3
0
        public void TestWrongNumberOfArgs3()
        {
            Lunar.RegisterCommand("action", (string arg1, string arg2) =>
            {
                Assert.Fail("Command should not get executed");
            });

            Execute("action arg1 arg2 arg3", false);
            AssertResult("  Wrong number of arguments", "  usage: action <arg1> <arg2>");
        }
Beispiel #4
0
        public void TestStringArg()
        {
            Lunar.RegisterCommand("action", (string arg) =>
            {
                AddResult("action " + arg);
            });

            Execute("action arg1");
            AssertResult("action arg1");
        }
Beispiel #5
0
        public void TestFloatArg3()
        {
            Lunar.RegisterCommand("action", (float arg1, float arg2, float arg3) =>
            {
                AddResult("action " + arg1 + " " + arg2 + " " + arg3);
            });

            Execute("action 3.14 3.15 3.16");
            AssertResult("action 3.14 3.15 3.16");
        }
Beispiel #6
0
        public void TestStringArg3()
        {
            Lunar.RegisterCommand("action", (string arg1, string arg2, string arg3) =>
            {
                AddResult("action " + arg1 + " " + arg2 + " " + arg3);
            });

            Execute("action arg1 arg2 arg3");
            AssertResult("action arg1 arg2 arg3");
        }
Beispiel #7
0
        public void TestVector4()
        {
            Lunar.RegisterCommand("action", (Vector4 arg) =>
            {
                AddResult("action " + arg);
            });

            Execute("action 1.0 2.0 3.0 4.0");
            AssertResult("action (1.0, 2.0, 3.0, 4.0)");
        }
Beispiel #8
0
        public void TestFloat3()
        {
            Lunar.RegisterCommand("action", (float[] args) =>
            {
                AddResult("action " + CStringUtils.Join(args, " "));
            });

            Execute("action 3.14 3.15 3.16");
            AssertResult("action 3.14 3.15 3.16");
        }
Beispiel #9
0
        public void TestInts3()
        {
            Lunar.RegisterCommand("action", (int[] args) =>
            {
                AddResult("action " + CStringUtils.Join(args, " "));
            });

            Execute("action 10 20 30");
            AssertResult("action 10 20 30");
        }
Beispiel #10
0
        public void TestFloatArg()
        {
            Lunar.RegisterCommand("action", (float arg) =>
            {
                AddResult("action " + arg);
            });

            Execute("action 3.14");
            AssertResult("action 3.14");
        }
Beispiel #11
0
 protected void RegisterCommands(params string[] names)
 {
     foreach (string name in names)
     {
         Lunar.RegisterCommand(name, delegate(string[] args)
         {
             AddResult(name);
         });
     }
 }
Beispiel #12
0
        public void TestIntArg()
        {
            Lunar.RegisterCommand("action", (int arg) =>
            {
                AddResult("action " + arg);
            });

            Execute("action 10");
            AssertResult("action 10");
        }
Beispiel #13
0
        public void TestIntArg3()
        {
            Lunar.RegisterCommand("action", (int arg1, int arg2, int arg3) =>
            {
                AddResult("action " + arg1 + " " + arg2 + " " + arg3);
            });

            Execute("action 10 20 30");
            AssertResult("action 10 20 30");
        }
Beispiel #14
0
        public void TestBoolArg()
        {
            Lunar.RegisterCommand("action", (bool arg) =>
            {
                AddResult("action " + arg);
            });

            Execute("action 1");
            AssertResult("action True");
        }
Beispiel #15
0
        public void TestBoolArg3()
        {
            Lunar.RegisterCommand("action", (bool arg1, bool arg2, bool arg3) =>
            {
                AddResult("action " + arg1 + " " + arg2 + " " + arg3);
            });

            Execute("action 1 0 1");
            AssertResult("action True False True");
        }
Beispiel #16
0
        public void TestBool3()
        {
            Lunar.RegisterCommand("action", (bool[] args) =>
            {
                AddResult("action " + CStringUtils.Join(args, " "));
            });

            Execute("action 1 0 1");
            AssertResult("action True False True");
        }
Beispiel #17
0
        public void TestDelegateActionCommand()
        {
            Lunar.RegisterCommand("action", (string[] args) =>
            {
                AddResult("action: {0}", CStringUtils.Join(args, ", "));
            });

            Execute("action arg1 arg2 arg3");
            AssertResult("action: arg1, arg2, arg3");
        }
Beispiel #18
0
        public void TestWrongNumberOfArgs()
        {
            Lunar.RegisterCommand("action", () =>
            {
                Assert.Fail("Command should not get executed");
            });

            Execute("action arg", false);
            AssertResult("  Wrong number of arguments", "  usage: action");
        }
Beispiel #19
0
        public void TestStrings3()
        {
            Lunar.RegisterCommand("action", (string[] args) =>
            {
                AddResult("action " + CStringUtils.Join(args, " "));
            });

            Execute("action arg1 arg2 arg3");
            AssertResult("action arg1 arg2 arg3");
        }
Beispiel #20
0
        public void TestDelegateAction()
        {
            Lunar.RegisterCommand("action", () =>
            {
                AddResult("action");
            });

            Execute("action");
            AssertResult("action");
        }
        public void SetUp()
        {
            RunSetUp();

            RegisterCommand(typeof(Cmd_alias));
            RegisterCommand(typeof(Cmd_unalias));

            Lunar.RegisterCommand("echo", delegate(CCommand cmd, string[] args)
            {
                AddResult(cmd.CommandString);
            });
        }
Beispiel #22
0
        public void TestUnregisterDelegateActionCommand()
        {
            Lunar.RegisterCommand("action", (string[] args) =>
            {
                AddResult("action");
            });

            CRegistery.Unregister("action");

            Execute("action", false);
            AssertResult("action: command not found"); // FIXME
        }
Beispiel #23
0
        public void SetUp()
        {
            RunSetUp();

            RegisterCommand(typeof(Cmd_bind));
            RegisterCommand(typeof(Cmd_unbind));
            RegisterCommand(typeof(Cmd_bindlist));

            Lunar.RegisterCommand("test", delegate(CCommand cmd, string[] args)
            {
                AddResult(cmd.CommandString);
            });
        }
Beispiel #24
0
        public void TestRegisterMethodsCommands()
        {
            CRegistery.Clear();

            Lunar.RegisterCommand("del1", Del1);
            Lunar.RegisterCommand("del2", Del2);
            Lunar.RegisterCommand("del3", Del3);

            IList <CCommand> cmds = CRegistery.ListCommands("del");

            Assert.AreEqual(3, cmds.Count);
            Assert.AreEqual("del1", cmds[0].Name);
            Assert.AreEqual("del2", cmds[1].Name);
            Assert.AreEqual("del3", cmds[2].Name);
        }
Beispiel #25
0
        public void TestActionChain()
        {
            Lunar.RegisterCommand("action1", () =>
            {
                AddResult("action1");
            });

            Lunar.RegisterCommand("action2", () =>
            {
                AddResult("action2");
            });

            Execute("action1 && action2");
            AssertResult("action1", "action2");
        }
Beispiel #26
0
        public void TestOverrideDelegateActionCommand()
        {
            Lunar.RegisterCommand("action", (string[] args) =>
            {
                AddResult("action");
            });

            Lunar.RegisterCommand("action", (string[] args) =>
            {
                AddResult("new action");
            });

            Execute("action");
            AssertResult("new action");
        }
        protected override void RunSetUp()
        {
            base.RunSetUp();

            RegisterCommand(typeof(Cmd_alias));

            Execute("alias test1 test");
            Execute("alias test12 test");
            Execute("alias test2 test");
            Execute("alias foo test");

            RegisterCommand(typeof(Cmd_test3), false);
            new CVar("test4", 0);

            Lunar.RegisterCommand("test5", delegate() {}); // delegate should be ignored
        }
        protected override void RunSetUp()
        {
            base.RunSetUp();

            RegisterCommand(typeof(Cmd_cmdlist));
            RegisterCommand(typeof(Cmd_alias));
            RegisterCommand(typeof(Cmd_test1), false);
            RegisterCommand(typeof(Cmd_foo), false);
            RegisterCommand(typeof(Cmd_test3), false);
            RegisterCommand(typeof(Cmd_test4), true); // hidden
            RegisterCommand(typeof(Cmd_test5), false);

            new CVar("var", 0);                             // var should be ignored
            Lunar.RegisterCommand("test12", delegate() {}); // delegate
            Execute("alias test2 test1");
        }
        protected override void RunSetUp()
        {
            base.RunSetUp();

            RegisterCommand(typeof(Cmd_man));
            RegisterCommand(typeof(Cmd_alias));
            RegisterCommand(typeof(Cmd_test1), false);
            RegisterCommand(typeof(Cmd_test12), false);
            RegisterCommand(typeof(Cmd_test2), false);
            RegisterCommand(typeof(Cmd_foo), false);
            RegisterCommand(typeof(Cmd_hidden));
            RegisterCommand(typeof(Cmd_debug), false);
            RegisterCommand(typeof(Cmd_system), false);

            new CVar("var", 0);                               // cvar should be ignored
            Execute("alias test test1");                      // alias should be ignored
            Lunar.RegisterCommand("delegate", delegate() {}); // delegate should be ignored
        }
Beispiel #30
0
        protected override void RunSetUp()
        {
            base.RunSetUp();

            new CVar("test1", 0);
            new CVar("test12", 0);
            new CVar("test2", 0);
            new CVar("foo", 0);
            new CVar("debug", 0, CFlags.Debug);

            RegisterCommand(typeof(Cmd_test3), false);
            RegisterCommand(typeof(Cmd_reset));
            RegisterCommand(typeof(Cmd_alias));

            Execute("alias test4 test1");

            Lunar.RegisterCommand("test5", delegate() {}); // delegate should be ignored
        }