コード例 #1
0
        public void FindCommandTest()
        {
            Native.NativeLoader = new NoNativeLoader();

            Action <string, string, string, bool> action = (methodName, commandPath, runCommand, expectSuccess) =>
            {
                var manager        = new CommandsManager(new TestGameMode());
                var expectedMethod = GetType().GetMethod(methodName);
                manager.Register(new[] { new CommandPath(commandPath) }, null, false, null, expectedMethod, null);

                var actualCommand = (manager.GetCommandForText(new BasePlayer(), runCommand) as DefaultCommand)?.Method;

                if (expectSuccess)
                {
                    Assert.AreEqual(expectedMethod, actualCommand);
                }
                else
                {
                    Assert.AreNotEqual(expectedMethod, actualCommand);
                }
            };

            action("A", "cmd a", "/cmd a", true);
            action("A", "cmd a", "/cmd a a", true);
            action("A", "cmd b", "/cmd a", false);
            action("A", "cmd c a", "/cmd c", false);
        }
コード例 #2
0
        public void FindCommandTest()
        {
            Action<string, string, string, bool> action = (methodName, commandPath, runCommand, expectSuccess) =>
            {
                var manager = new CommandsManager(new TestGameMode());
                var expectedMethod = GetType().GetMethod(methodName);
                manager.Register(new[] {new CommandPath(commandPath)}, null, false, null, expectedMethod, null);

                var actualCommand = (manager.GetCommandForText(new BasePlayer(), runCommand) as DefaultCommand)?.Method;

                if (expectSuccess)
                    Assert.AreEqual(expectedMethod, actualCommand);
                else
                    Assert.AreNotEqual(expectedMethod, actualCommand);
            };

            action("A", "cmd a", "/cmd a", true);
            action("A", "cmd a", "/cmd a a", true);
            action("A", "cmd b", "/cmd a", false);
            action("A", "cmd c a", "/cmd c", false);
        }