Example #1
0
        public void AddShape_WithMultipleShapes_ShouldAddShapesToPictureDraft()
        {
            var pictureDraft = new PictureDraft();
            var shape1       = new TestShape(Color.Blue);
            var shape2       = new TestShape(Color.Green);

            Assert.AreEqual(0, pictureDraft.ShapeCount);
            pictureDraft.AddShape(shape1);
            pictureDraft.AddShape(shape2);
            Assert.AreEqual(2, pictureDraft.ShapeCount);
        }
Example #2
0
        public void CanCreatePainterAndDrawShapes()
        {
            var painter = new Painter();
            var canvas  = new Canvas();
            var draft   = new PictureDraft();
            var shape1  = new TestShape();
            var shape2  = new TestShape();

            draft.AddShape(shape1);
            draft.AddShape(shape2);
            painter.DrawPicture(draft, canvas);

            Assert.IsTrue(shape1.IsActivated);
            Assert.IsTrue(shape2.IsActivated);
        }
Example #3
0
        public void CanShape_ByIndex_ShouldGetShape()
        {
            var pictureDraft = new PictureDraft();
            var shape        = new TestShape(Color.Blue);

            pictureDraft.AddShape(shape);
            Assert.AreEqual(shape, pictureDraft.GetShape(0));
        }
Example #4
0
        public void GetShape_ByIndexOutOfRange_ShouldThrowException()
        {
            var pictureDraft = new PictureDraft();
            var shape        = new TestShape(Color.Blue);

            pictureDraft.AddShape(shape);
            pictureDraft.GetShape(-1);
            pictureDraft.GetShape(2);
        }
Example #5
0
        public PictureDraft CreateDraft(TextReader strm)
        {
            IsDraftCreated = true;
            var draft = new PictureDraft();

            draft.AddShape(new Rectangle(new Point(0, 3), new Point(2, -2), Task1.Painter.Enums.Color.Black));

            return(draft);
        }
Example #6
0
        public void CantGetShapeIfIndexLessThanZero()
        {
            var draft     = new PictureDraft();
            var testShape = new TestShape();

            Assert.AreEqual(draft.ShapeCount, 0);
            draft.AddShape(testShape);
            Assert.AreEqual(draft.ShapeCount, 1);
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => draft.GetShapeByIndex(-1));
        }
Example #7
0
        public void CanGetShapeByIndex()
        {
            var draft     = new PictureDraft();
            var testShape = new TestShape();

            Assert.AreEqual(draft.ShapeCount, 0);
            draft.AddShape(testShape);
            Assert.AreEqual(draft.ShapeCount, 1);
            Assert.AreEqual(draft.GetShapeByIndex(0), testShape);
        }
Example #8
0
        public void CanCreatePictureDraftAndAddShapeInIt()
        {
            var draft     = new PictureDraft();
            var testShape = new TestShape();

            Assert.AreEqual(draft.ShapeCount, 0);
            draft.AddShape(testShape);

            Assert.AreEqual(draft.ShapeCount, 1);
        }
Example #9
0
        public void DrawPicture_WithShapeAndCanvas_ShouldDrawPicture()
        {
            var painter      = new Painter.Painter();
            var pictureDraft = new PictureDraft();
            var rectangle    = new Rectangle(new Point(150, 150), new Point(10, 300), Color.Blue);
            var ellipse      = new Ellipse(new Point(200, 200), 100, 75, Color.Yellow);
            var sw           = new StringWriter();
            var canvas       = new TestCanvas(sw);

            pictureDraft.AddShape(rectangle);
            pictureDraft.AddShape(ellipse);
            painter.DrawPicture(pictureDraft, canvas);

            string expected = "Blue line from (150, 150), to (10, 150)\r\n" +
                              "Blue line from (10, 150), to (10, 300)\r\n" +
                              "Blue line from (10, 300), to (150, 300)\r\n" +
                              "Blue line from (150, 300), to (150, 150)\r\n" +
                              "Yellow ellipse with center: (200, 200); width: 200; height: 150\r\n";

            Assert.AreEqual(expected, sw.ToString());
        }