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 DrawPicture(PictureDraft pictureDraft, ICanvas canvas) { foreach (BaseShape shape in pictureDraft.Shapes) { Console.WriteLine($"Shape: {shape.GetType().Name}"); shape.Draw(canvas); Console.WriteLine($"-----------------------------"); } }
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 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 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()); }
public void CreateDraft() { // Arrange IShapeFactory shapeFactory = new ShapeFactory(); var designer = new Designer.Designer(shapeFactory); var shapeDecriptions = new List <string> { "Triangle red 0 0 1 0 1 1", "RegularPolygon yellow 3 2 0 0" }; // Act PictureDraft draft = designer.CreateDraft(shapeDecriptions); List <BaseShape> shapes = draft?.Shapes; // Assert Assert.NotNull(shapes); Assert.Equal(2, draft.Shapes.Count); Assert.Contains(shapes, s => s.GetType() == typeof(Triangle)); Assert.Contains(shapes, s => s.GetType() == typeof(RegularPolygon)); }
public void DrawPicture(PictureDraft draft, ICanvas canvas) { WasDrawed = true; }