public void Test_CmdC_Negative_Width()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            String[] parameters4B = { "10", "-5" }; //negative
            Assert.IsTrue(cmd.Execute(parameters4B) == -1);
        }
        public void Test_CmdC_ExtraParam()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            String[] parameters2 = { "10", "5", "4" };
            Assert.IsTrue(cmd.Execute(parameters2) == -1);
        }
        public void Test_CmdC_Invalid_Height()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            String[] parameters3 = { "10", "f" };
            Assert.IsTrue(cmd.Execute(parameters3) == -1);
        }
        public void Test_CmdC_Good()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            String[] parameters1 = { "10", "5" };
            Assert.IsTrue(cmd.Execute(parameters1) == 0);
        }
        public void Test_CmdC_Max_Canvas_Size_Exceeded()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            String[] parameters1 = { "110", "5" };
            Assert.IsTrue(cmd.Execute(parameters1) == -1);
        }
Esempio n. 6
0
        public void Test_CmdR_Rectangle_Before_Canvas()
        {
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdR = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('r'));;

            String[] parametersC  = { "20", "4" };
            String[] parametersR1 = { "16", "1", "20", "3" }; // correct parameters
            Assert.IsTrue(cmdR.Execute(parametersR1) == -1);
        }
        public void Test_CmdL_LineBeforeCanvas()
        {
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdL = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));

            String[] parametersC  = { "20", "4" };
            String[] parametersL1 = { "1", "2", "6", "2" }; // correct parameters
            Assert.IsTrue(cmdL.Execute(parametersL1) == -1);
        }
        public void Test_CmdB_Fill_Before_Canvas()
        {
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            Assert.IsTrue(cmdC is CmdC);
            Assert.IsTrue(cmdB is CmdB);
            String[] parametersB1 = { "10", "3", "O" }; // correct parameters
            String[] parametersC  = { "20", "4" };
            Assert.IsTrue(cmdB.Execute(parametersB1) == -1);
        }
Esempio n. 9
0
        public void Test_CmdR_Point1_Outside_Boundary_X()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdR = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('r'));;

            String[] parametersC   = { "20", "4" };
            String[] parametersR5a = { "6", "3", "24", "3" }; // out of canvas boundary
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdR.BaseCanvas = canvas;
            Assert.IsTrue(cmdR.Execute(parametersR5a) == -1);
        }
Esempio n. 10
0
        public void Test_CmdR_Insufficient_Param()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdR = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('r'));;

            String[] parametersC  = { "20", "4" };
            String[] parametersR4 = { "16", "1", "20" };
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdR.BaseCanvas = canvas;
            Assert.IsTrue(cmdR.Execute(parametersR4) == -1);
        }
Esempio n. 11
0
        public void Test_CmdR_Point2_NegX()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdR = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('r'));;

            String[] parametersC   = { "20", "4" };
            String[] parametersR6c = { "6", "3", "-6", "4" }; // negative coordinates
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdR.BaseCanvas = canvas;
            Assert.IsTrue(cmdR.Execute(parametersR6c) == -1);
        }
        public void Test_CmdL_Point1_X_OutsideCanvas()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdL = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));

            String[] parametersC   = { "20", "4" };
            String[] parametersL6a = { "6", "3", "22", "4" }; // out of canvas boundary
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdL.BaseCanvas = canvas;
            Assert.IsTrue(cmdL.Execute(parametersL6a) == -1);
        }
        public void Test_CmdL_Good()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdL = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));

            String[] parametersC  = { "20", "4" };
            String[] parametersL5 = { "6", "3", "6", "4" }; // correct parameters
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdL.BaseCanvas = canvas;
            Assert.IsTrue(cmdL.Execute(parametersL5) == 0);
        }
        public void Test_CmdL_ExtraParam()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdL = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));

            String[] parametersC  = { "20", "4" };
            String[] parametersL2 = { "1", "2", "6", "2", "2" };
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdL.BaseCanvas = canvas;
            Assert.IsTrue(cmdL.Execute(parametersL2) == -1);
        }
        public void Test_CmdL_Point2_NegY()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdL = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));

            String[] parametersC   = { "20", "4" };
            String[] parametersL7d = { "6", "3", "6", "-4" }; // negative coordinates
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdL.BaseCanvas = canvas;
            Assert.IsTrue(cmdL.Execute(parametersL7d) == -1);
        }
        public void Test_CmdB_NoColorParam()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            String[] parametersC  = { "20", "4" };
            String[] parametersB4 = { "10", "3" };
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdB.BaseCanvas = canvas;
            Assert.IsTrue(cmdB.Execute(parametersB4) == -1);
        }
        public void Test_CmdB_Height_Outside_Canvas()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            String[] parametersC   = { "20", "4" };
            String[] parametersB5b = { "6", "8", "8" }; // out of canvas boundary
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdB.BaseCanvas = canvas;
            Assert.IsTrue(cmdB.Execute(parametersB5b) == -1);
        }
        public void Test_CmdB_Ok()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            String[] parametersC  = { "20", "4" };
            String[] parametersB1 = { "10", "3", "0" }; // correct parameters
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdB.BaseCanvas = canvas;
            Assert.IsTrue(cmdB.Execute(parametersB1) == 0);
        }
        public void Test_CmdB_Invalid_Height()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            String[] parametersC  = { "20", "4" };
            String[] parametersB3 = { "10", "B", "O" };
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdB.BaseCanvas = canvas;
            Assert.IsTrue(cmdB.Execute(parametersB3) == -1);
        }
        public void Test_CmdB_Negative_Height()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            String[] parametersC   = { "20", "4" };
            String[] parametersB6b = { "6", "-3", "6" }; // negative coordinates
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdB.BaseCanvas = canvas;
            Assert.IsTrue(cmdB.Execute(parametersB6b) == -1);
        }
Esempio n. 21
0
        public void Test_CmdR_Good()
        {
            Canvas  canvas;
            Command cmdC = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));
            Command cmdR = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('r'));;

            String[] parametersC  = { "20", "4" };
            String[] parametersR1 = { "16", "1", "20", "3" }; // correct parameters
            cmdC.Execute(parametersC);
            canvas          = cmdC.BaseCanvas;
            cmdR.BaseCanvas = canvas;
            Assert.IsTrue(cmdR.Execute(parametersR1) == 0);
        }
Esempio n. 22
0
        public void DrawAllShapes()
        {
            Canvas canvas;

            CanvasConsoleHelper.GetCommand('c');

            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            Assert.IsTrue(cmd is CmdC);

            String[] parametersC  = { "20", "4" };
            String[] parametersL1 = { "1", "2", "6", "2" };
            String[] parametersL2 = { "6", "3", "6", "4" };
            String[] parametersR  = { "16", "1", "20", "3" };
            String[] parametersB  = { "10", "3", "0" };

            // create
            Assert.IsTrue(cmd.Execute(parametersC) == 0);
            canvas = cmd.BaseCanvas;

            // line
            cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));
            Assert.IsTrue(cmd is CmdL);
            cmd.BaseCanvas = canvas;
            Assert.IsTrue(cmd.Execute(parametersL1) == 0);
            Assert.IsTrue(cmd.Execute(parametersL2) == 0);

            // rectangle
            cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('R'));
            Assert.IsTrue(cmd is CmdR);
            cmd.BaseCanvas = canvas;
            Assert.IsTrue(cmd.Execute(parametersR) == 0);

            // bucket fill
            cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));
            Assert.IsTrue(cmd is CmdB);
            cmd.BaseCanvas = canvas;
            Assert.IsTrue(cmd.Execute(parametersB) == 0);
        }
Esempio n. 23
0
        public void Test_CmdR_VerifyCmd()
        {
            Command cmdR = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('r'));

            Assert.IsTrue(cmdR is CmdR);
        }
        public void Test_CmdL()
        {
            Command cmdL = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('L'));

            Assert.IsTrue(cmdL is CmdL);
        }
        public void Test_CmdC_Verify_Cmd()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            Assert.IsTrue(cmd is CmdC);
        }
        public void Test_CmdB()
        {
            Command cmdB = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('B'));

            Assert.IsTrue(cmdB is CmdB);
        }
        public void Test_CmdC_NullParam()
        {
            Command cmd = CommandFactory.GetCommand(CanvasConsoleHelper.GetCommand('c'));

            Assert.IsTrue(cmd.Execute(null) == -1);
        }