public void TestClearShapes() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); compositeShape.AddShape(sf.MakeCircle(3, 2, 2)); compositeShape.AddShape(sf.MakePoint(1, 1)); Assert.AreEqual(compositeShape.GetShapes().Count, 2); compositeShape.ClearShapes(); Assert.AreEqual(compositeShape.GetShapes().Count, 0); }
public void TestAddShape() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); Circle testCircle = sf.MakeCircle(3, 2, 2); compositeShape.AddShape(testCircle); Assert.AreEqual(testCircle, compositeShape.GetShapes()[0]); }
public void TestComputeArea() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(2, 3); Assert.AreEqual(compositeShape.ComputeArea(), 0); compositeShape.AddShape(sf.MakeCircle(1, 2, 5)); Assert.AreEqual(78.53975, compositeShape.ComputeArea(), 0.0001); }
public void TestRemoveShape() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); Circle testCircle = sf.MakeCircle(3, 2, 2); compositeShape.AddShape(testCircle); Assert.AreEqual(1, compositeShape.GetShapes().Count); compositeShape.RemoveShape(0); Assert.AreEqual(0, compositeShape.GetShapes().Count); }
public void TestDraw() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); compositeShape.AddShape(sf.MakeCircle(2, 2, 2)); Bitmap bitmap = new Bitmap(1024, 1024, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bitmap); compositeShape.Draw(g); bitmap.Save("compositeShape.bmp"); }