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); }
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); }
public void CanShape_ByIndex_ShouldGetShape() { var pictureDraft = new PictureDraft(); var shape = new TestShape(Color.Blue); pictureDraft.AddShape(shape); Assert.AreEqual(shape, pictureDraft.GetShape(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); }
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); }
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)); }
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); }
public void CanCreatePictureDraftAndAddShapeInIt() { var draft = new PictureDraft(); var testShape = new TestShape(); Assert.AreEqual(draft.ShapeCount, 0); draft.AddShape(testShape); Assert.AreEqual(draft.ShapeCount, 1); }
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()); }