public void TestCreationOfValidRectangle(int x1, int y1, int x2, int y2, char mchar)
        {
            //create valid canvas
            int width  = 20;
            int height = 4;

            CoreProcesses process = new CoreProcesses();

            Canvas createdCanvas = process.CreateCanvas(width, height);
            Canvas testCanvas    = process.CreateCanvas(width, height);

            createdCanvas = process.DrawRectangle(x1, y1, x2, y2, mchar, createdCanvas);

            testCanvas = process.DrawLine(x1, y1, x2, y1, mchar, testCanvas);
            testCanvas = process.DrawLine(x1, y1, x1, y2, mchar, testCanvas);
            testCanvas = process.DrawLine(x2, y1, x2, y2, mchar, testCanvas);
            testCanvas = process.DrawLine(x1, y2, x2, y2, mchar, testCanvas);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Assert.True(createdCanvas.CanvasBody[i, j] == testCanvas.CanvasBody[i, j]);
                }
            }
        }
Beispiel #2
0
        public void TestCreationOfValidCanvas(int width, int height)
        {
            CoreProcesses process       = new CoreProcesses();
            Canvas        createdCanvas = process.CreateCanvas(width, height);

            Assert.NotNull(createdCanvas);
        }
Beispiel #3
0
        public void TestCreationOfInvalidCanvas(int width, int height)
        {
            CoreProcesses process = new CoreProcesses();

            Exception ex = Assert.Throws <Exception>(
                () => process.CreateCanvas(width, height)
                );

            if (width > 77)
            {
                Assert.Equal("MaxWidthExceededException", ex.Message);
            }
            else
            {
                Assert.Equal("InvalidCanvasWidthAndHeightException", ex.Message);
            }
        }
        public void TestInvalidBucketFillDueToSize(int x, int y, char mchar)
        {
            //create valid canvas
            int width  = 20;
            int height = 4;

            Canvas        canvasToTest = null;
            CoreProcesses process      = new CoreProcesses();

            Canvas createdCanvas = process.CreateCanvas(width, height);

            //Test Scenario: x & y axis is greater than canvas size and some negative value
            if (x > width || y > height)
            {
                Exception ex = Assert.Throws <IndexOutOfRangeException>(
                    () => canvasToTest = process.BucketFill(x, y, mchar, createdCanvas)
                    );
            }
        }
        public void TestCreationOfInvalidRectangleDueToSize(int x1, int y1, int x2, int y2, char mchar)
        {
            //create valid canvas
            int width  = 20;
            int height = 4;

            CoreProcesses process = new CoreProcesses();

            Canvas createdCanvas = process.CreateCanvas(width, height);

            //Test Scenario: x & y axis is greater than canvas size and some negative value
            if (x1 > width || x2 > width || y1 > height || y2 > height)
            {
                Exception ex = Assert.Throws <IndexOutOfRangeException>(
                    () => createdCanvas = process.DrawRectangle(x1, y1, x2, y2, mchar, createdCanvas)
                    );
                return;
            }
        }
        public void TestValidBucketFill(int x, int y, char mchar)
        {
            //create valid canvas
            int width  = 20;
            int height = 4;

            CoreProcesses process       = new CoreProcesses();
            Canvas        createdCanvas = process.CreateCanvas(width, height);

            createdCanvas = process.BucketFill(x, y, mchar, createdCanvas);

            Assert.NotNull(createdCanvas);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Assert.True(createdCanvas.CanvasBody[i, j] != ' ');
                }
            }
        }
        public void TestDrawValidLine(int x1, int y1, int x2, int y2, char mchar)
        {
            //create valid canvas
            int width  = 20;
            int height = 4;

            Canvas        canvasToTest = null;
            char          foundLiteral = ' ';
            CoreProcesses process      = new CoreProcesses();

            Canvas createdCanvas = process.CreateCanvas(width, height);

            canvasToTest = process.DrawLine(x1, y1, x2, y2, mchar, createdCanvas);

            for (int i = y1; i <= y2; i++)
            {
                for (int j = x1; j <= x2; j++)
                {
                    foundLiteral = canvasToTest.CanvasBody[i, j];
                    Assert.True(foundLiteral == mchar);
                }
            }
        }
        public void TestInvalidCharInCanvas(int x1, int y1, int x2, int y2, char mchar)
        {
            //create valid canvas
            int width  = 20;
            int height = 4;

            char          foundLiteral = ' ';
            char          invalidmchar = 'Y';
            CoreProcesses process      = new CoreProcesses();

            Canvas createdCanvas = process.CreateCanvas(width, height);

            createdCanvas = process.DrawLine(x1, y1, x2, y2, mchar, createdCanvas);

            //Test incorrect character used to write line
            for (int i = y1; i <= y2; i++)
            {
                for (int j = x1; j <= x2; j++)
                {
                    foundLiteral = createdCanvas.CanvasBody[i, j];
                    Assert.False(foundLiteral == invalidmchar);
                }
            }
        }