Beispiel #1
0
        public void DrawBucketFill_OutsideRectangle_RectangleFilled()
        {
            string[] expected = new string[]
            {
                "----------------------",
                "|cccccccccccccccccccc|",
                "|ccxxxxxccccccccccccc|",
                "|ccx   xccccccccccccc|",
                "|ccx   xccccccccccccc|",
                "|ccxxxxxccccccccccccc|",
                "----------------------"
            };

            Canvas    canvas    = new Canvas(20, 5);
            Rectangle rectangle = new Rectangle(3, 2, 7, 5);

            canvas.Shapes.Add(rectangle);
            canvas.Draw();

            BucketFill bucketFillOutsideRectangle = new BucketFill(10, 4, "c");

            string[] actual = bucketFillOutsideRectangle.Draw(canvas);

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void DrawBucketFill_BottomOnCanvasWithHorizontalLine_BottomSideCanvasFilled()
        {
            string[] expected = new string[]
            {
                "----------------------",
                "|                    |",
                "|                    |",
                "|xxxxxxxxxxxxxxxxxxxx|",
                "|cccccccccccccccccccc|",
                "|cccccccccccccccccccc|",
                "----------------------"
            };

            Canvas canvas         = new Canvas(20, 5);
            Line   horizontalLine = new Line(1, 3, 20, 3);

            canvas.Shapes.Add(horizontalLine);
            canvas.Draw();

            BucketFill bucketFillBottomCanvas = new BucketFill(5, 4, "c");

            string[] actual = bucketFillBottomCanvas.Draw(canvas);

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void DrawBucketFill_OutsideCanvas_ThrowsDrawException()
        {
            Canvas canvas = new Canvas(20, 5);

            canvas.Draw();

            BucketFill bucketFillOutsideRectangle = new BucketFill(30, 2, "c");
            Action     actual = () => bucketFillOutsideRectangle.Draw(canvas);

            Exception ex = Assert.ThrowsException <DrawingException>(actual);

            Assert.AreEqual(ExceptionMessages.SHAPE_MUST_BE_DRAWN_INSIDE_CANVAS, ex.Message);
        }
Beispiel #4
0
        public void DrawBucketFill_OnAlreadyExistentLine_ThrowsDrawException()
        {
            Canvas canvas = new Canvas(20, 5);
            Line   line   = new Line(2, 2, 5, 2);

            canvas.Shapes.Add(line);
            canvas.Draw();

            BucketFill bucketFillOutsideRectangle = new BucketFill(3, 2, "c");
            Action     actual = () => bucketFillOutsideRectangle.Draw(canvas);

            Exception ex = Assert.ThrowsException <DrawingException>(actual);

            Assert.AreEqual(ExceptionMessages.BUCKET_FILL_MUST_BE_CREATED_ON_EMPTY_POINT, ex.Message);
        }
Beispiel #5
0
        public void DrawBucketFill_EmptyCanvas_CanvasFilled()
        {
            string[] expected = new string[]
            {
                "----------------------",
                "|cccccccccccccccccccc|",
                "|cccccccccccccccccccc|",
                "|cccccccccccccccccccc|",
                "|cccccccccccccccccccc|",
                "----------------------"
            };

            Canvas canvas = new Canvas(20, 4);

            canvas.Draw();

            BucketFill bucketFillAllCanvas = new BucketFill(10, 2, "c");

            string[] actual = bucketFillAllCanvas.Draw(canvas);

            CollectionAssert.AreEqual(expected, actual);
        }
Beispiel #6
0
        public void DrawBucketFill_LeftOnCanvasWithVerticalLine_LeftSideCanvasFilled()
        {
            string[] expected = new string[]
            {
                "----------------------",
                "|cccccccccx          |",
                "|cccccccccx          |",
                "|cccccccccx          |",
                "|cccccccccx          |",
                "----------------------"
            };

            Canvas canvas       = new Canvas(20, 4);
            Line   verticalLine = new Line(10, 1, 10, 4);

            canvas.Shapes.Add(verticalLine);
            canvas.Draw();

            BucketFill bucketFillLeftSide = new BucketFill(5, 3, "c");

            string[] actual = bucketFillLeftSide.Draw(canvas);

            CollectionAssert.AreEqual(expected, actual);
        }