Exemple #1
0
        public void TestHandleCommand_whenCommandNotFound_thenThrowException()
        {
            var env           = new CompilerEnvironment();
            var line          = "test arg1";
            var commands      = new Dictionary <string, CommandProcessorFactory.CommandProcessor>();
            var compilerModel = new CompilerModel(null, null, commands);

            compilerModel.HandleCommand(line, env);
        }
Exemple #2
0
        public void TestHandleCommand_whenCommandWithoutArgs_thenArgumentsEmpty()
        {
            var env      = new CompilerEnvironment();
            var line     = "tEsT";
            var commands = new Dictionary <string, CommandProcessorFactory.CommandProcessor> {
                {
                    "test",
                    (args, innerEnv) => {
                        Assert.AreSame(innerEnv, env);
                        Assert.AreEqual(args.Length, 0);
                    }
                }
            };
            var compilerModel = new CompilerModel(null, null, commands);

            compilerModel.HandleCommand(line, env);
        }
Exemple #3
0
        public void TestHandleCommand_whenCommandCorrect_thenArgumentsPassed()
        {
            var env      = new CompilerEnvironment();
            var line     = "tEsT arg1  , arg2 ";
            var commands = new Dictionary <string, CommandProcessorFactory.CommandProcessor> {
                {
                    "test",
                    (args, innerEnv) => {
                        Assert.AreSame(innerEnv, env);
                        Assert.AreEqual(args.Length, 2);
                        Assert.IsTrue(args[0].Equals("arg1"));
                        Assert.IsTrue(args[1].Equals("arg2"));
                    }
                }
            };
            var compilerModel = new CompilerModel(null, null, commands);

            compilerModel.HandleCommand(line, env);
        }