Ejemplo n.º 1
0
        public void TestMakeMoveCommand()
        {
            ScriptParser sp = new ScriptParser();

            Assert.IsInstanceOf(typeof(MoveCommand),
                                sp.MakeCommand(CommandType.Move,
                                               new List <string> {
                "a", "b"
            }, "fake_path"));

            Assert.Throws <ScriptParserException>(
                () => sp.MakeCommand(CommandType.Move,
                                     new List <string> {
                "a"
            }, "fake_path"));
        }
Ejemplo n.º 2
0
        public void TestMakeExecuteCommand()
        {
            string callerPath = Path.Combine(
                TestConstants.TestDirectory, "caller");

            string calleePath = Path.Combine(
                TestConstants.TestDirectory, "callee");

            File.WriteAllText(calleePath, "");

            string invalidScriptPath = Path.Combine(
                TestConstants.TestDirectory, "invalidScript");

            File.WriteAllText(invalidScriptPath, "create_file");

            ScriptParser sp = new ScriptParser();

            Assert.IsInstanceOf(typeof(Script),
                                sp.MakeCommand(CommandType.Execute,
                                               new List <string> {
                "callee"
            }, callerPath));

            Assert.Throws <ScriptParserException>(
                () => sp.MakeCommand(CommandType.Execute,
                                     new List <string> {
                "callee", "badArgument"
            }, callerPath));
            Assert.Throws <FileNotFoundException>(
                () => sp.MakeCommand(CommandType.Execute,
                                     new List <string> {
                "fake"
            }, callerPath));
            Assert.Throws <ScriptParserException>(
                () => sp.MakeCommand(CommandType.Execute,
                                     new List <string> {
                "invalidScript"
            }, callerPath));
        }