Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
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]);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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");
        }