public void creation()
        {
            //preconfig
            int cols = 20;
            int rows = 20;
            int width = 400;
            int height = 600;

            int expectedFieldHeight = height / rows;
            int expectedFieldWidth = width / cols;

            //creation
            BoundingRaster br = new BoundingRaster(cols, rows, width, height);

            //operation
            int realCols = br.Cols;
            int realRows = br.Rows;
            int realWidth = br.Width;
            int realHeight = br.height;

            double realFieldHeight = br.FieldHeight;
            double realFieldWidth = br.FieldWidth;

            //assertion
            Assert.IsNotNull(br);
            Assert.AreEqual(cols, realCols);
            Assert.AreEqual(rows, realRows);
            Assert.AreEqual(width, realWidth);
            Assert.AreEqual(height, realHeight);
            Assert.AreEqual(expectedFieldHeight, realFieldHeight, 0.1);
            Assert.AreEqual(expectedFieldWidth, realFieldWidth, 0.1);
        }
        public void TakeOverBoundingContainerWithCircleBigCenter()
        {
            //preconfig
            int cols = 10;
            int rows = 10;
            int width = 100;
            int height = 100;

            int expectedFieldHeight = height / rows;
            int expectedFieldWidth = width / cols;

            int radius1 = 50;
            Vector position1 = new Vector(0, 0);

            //creation
            BoundingRaster br = new BoundingRaster(cols, rows, width, height);

            Bumper parent1 = new Bumper();
            BoundingCircle bC1 = new BoundingCircle(radius1, position1);
            BoundingContainer bCont1 = new BoundingContainer(parent1);
            bCont1.AddBoundingBox(bC1);
            parent1.Location = (new Vector(0, 0));

            //operation
            br.TakeOverBoundingContainer(bCont1);

            //assertion
            for (int x = 0; x < cols; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    if (x <= 9 && x >= 0 && y <= 9 && y >= 0)
                    {
                        bool found = false;
                        foreach (IBoundingBox b in br.GetBoundingField(x, y).getReferences())
                        {
                            Assert.AreEqual(bC1, b);
                            found = true;
                        }
                        if (!found)
                        {
                            Assert.Fail();
                        }
                    }
                    else
                    {
                        foreach (IBoundingBox b in br.GetBoundingField(x, y).getReferences())
                        {
                            if (bC1.Equals(b))
                            {
                                Assert.Fail();
                            }
                        }
                    }
                }
            }
        }
        public void TakeOverBoundingContainerWithLineSmallDiagonal()
        {
            //preconfig
            int cols = 10;
            int rows = 10;
            int width = 100;
            int height = 100;

            int expectedFieldHeight = height / rows;
            int expectedFieldWidth = width / cols;

            Vector position1 = new Vector(0, 0);
            Vector target1 = new Vector(50, 50);

            //creation
            BoundingRaster br = new BoundingRaster(cols, rows, width, height);

            Line parent1 = new Line();
            BoundingLine bL1 = new BoundingLine(position1, target1);
            BoundingContainer bCont1 = new BoundingContainer(parent1);
            bCont1.AddBoundingBox(bL1);
            parent1.Location = (new Vector(0, 0));

            //operation
            br.TakeOverBoundingContainer(bCont1);

            //assertion
            for (int x = 0; x < cols; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    if ((x == y) && x >= 0 && x <= 5)
                    {
                        bool found = false;
                        foreach (IBoundingBox b in br.GetBoundingField(x, y).getReferences())
                        {
                            Assert.AreEqual(bL1, b);
                            found = true;
                        }
                        if (!found)
                        {
                            Assert.Fail();
                        }
                    }
                    else
                    {
                        foreach (IBoundingBox b in br.GetBoundingField(x, y).getReferences())
                        {
                            if (bL1.Equals(b))
                            {
                                Assert.Fail();
                            }
                        }
                    }
                }
            }
        }
        public PinballGameMachine(PinballMachine machine)
            : base(machine.Layout.Clone() as IMachineLayout)
        {
            this.boundingRaster = new BoundingRaster((int)Math.Ceiling(Width / 60f), (int)Math.Ceiling(Height / 60f), Width, Height);

            // Copy constructor
            foreach (PinballElement element in machine.DynamicElements)
            {
                DynamicElements.Add((PinballElement)element.Clone());
            }
            Angle = machine.Angle;
            Gravity = machine.Gravity;
        }
        public void TakeOverBoundingContainerWithLineTotalOutside()
        {
            //preconfig
            int cols = 10;
            int rows = 10;
            int width = 100;
            int height = 100;

            int expectedFieldHeight = height / rows;
            int expectedFieldWidth = width / cols;

            Vector position1 = new Vector(-20, -20);
            Vector target1 = new Vector(-50, -50);

            //creation
            BoundingRaster br = new BoundingRaster(cols, rows, width, height);

            Line parent1 = new Line();
            BoundingLine bL1 = new BoundingLine(position1, target1);
            BoundingContainer bCont1 = new BoundingContainer(parent1);
            bCont1.AddBoundingBox(bL1);
            parent1.Location = (new Vector(0, 0));

            //operation
            br.TakeOverBoundingContainer(bCont1);

            //assertion
            for (int x = 0; x < cols; x++)
            {
                for (int y = 0; y < rows; y++)
                {

                    foreach (IBoundingBox b in br.GetBoundingField(x, y).getReferences())
                    {
                        if (bL1.Equals(b))
                        {
                            Assert.Fail();
                        }
                    }

                }
            }
        }
 /// <summary>
 /// No more elements can be added after this function call 
 /// </summary>
 public void prepareForLaunch()
 {
     LinkedList<IBoundingBox> anis = this.boundingRaster.getAnimatedObjects();
     this.boundingRaster = new BoundingRaster((int)Math.Ceiling(Width * 1f / Ball.Size.Width), (int)Math.Ceiling(Height * 1f / Ball.Size.Width), Width, Height);
     foreach (IBoundingBox b in anis)
     {
         this.boundingRaster.AddAnimatedObject(b);
     }
     this.boundingRaster.takeOverBoundingBoxes(StaticElements);
     this.boundingRaster.takeOverBoundingBoxes(DynamicElements);
 }