private void OnGenerateClick(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(rectanglesTextBox.Text))
            {
                if (int.Parse(rectanglesTextBox.Text) <= 2 || int.Parse(rectanglesTextBox.Text) > 30)
                {
                    Error.ForeColor = Color.Red;
                    Error.Text      = "Please enter numnber of Rectangles between 3 and 30";
                    this.Invalidate();
                }
                else
                {
                    Error.Text = "";

                    Graphics graphics           = this.CreateGraphics();
                    Pen      pen                = new Pen(Color.Red, 1);
                    var      inputYCoordinates  = 350;
                    var      outputYCoordinates = 80;

                    //Set (0,0) to the bottom of the screen
                    graphics.ScaleTransform(1.0f, -1.0f);
                    graphics.TranslateTransform(0, -this.ClientRectangle.Height);

                    //Generate Input Rectangles
                    var generatedInputRectangles = _rectanglesBuilder.GenerateInputRectangles(inputYCoordinates, int.Parse(rectanglesTextBox.Text));

                    _rectanglesBuilder.DrawRectanglesShapes(graphics, pen, generatedInputRectangles);

                    //Generate Output Rectangles
                    var generatedOutputRectangles = _rectanglesBuilder.GenerateOutputRectangles(generatedInputRectangles, outputYCoordinates);

                    _rectanglesBuilder.DrawRectanglesShapes(graphics, pen, generatedOutputRectangles);
                }
            }
        }
        public void GivenA_NumberOfRectangles_Which_Is_Less_Than_Three_MustThrowAnException()
        {
            var rectangleBuilder   = new RectanglesBuilder();
            var yCoordinates       = 80;
            var numberOfRectangles = 1;

            Assert.Throws <Exception>(() => rectangleBuilder.GenerateInputRectangles(yCoordinates, numberOfRectangles));
        }
        public void GivenA_NumberOfRectangles_Which_Is_Less_Than_Three_MustThrowAnExceptionMessage()
        {
            var rectangleBuilder   = new RectanglesBuilder();
            var yCoordinates       = 80;
            var numberOfRectangles = 1;

            var exception = Assert.Throws <Exception>(() => rectangleBuilder.GenerateInputRectangles(yCoordinates, numberOfRectangles));

            Assert.That(exception.Message, Is.EqualTo("Please enter No Of Rectangles between 3 and 30"));
        }
        public void GivenA_NumberOfRectangles_MustReturnAutoGeneratedRectangles()
        {
            var rectangleBuilder   = new RectanglesBuilder();
            var yCoordinates       = 80;
            var numberOfRectangles = 5;

            var results = rectangleBuilder.GenerateInputRectangles(yCoordinates, numberOfRectangles);

            Assert.AreEqual(results.Count, 5);
        }
        public void Given_AListOfGeneratedInputRectangles_MustReturnAListOfOutputRectangles()
        {
            var rectangleBuilder   = new RectanglesBuilder();
            var yCoordinates       = 80;
            var numberOfRectangles = 5;

            var generatedRectanglesInputList = rectangleBuilder.GenerateInputRectangles(yCoordinates, numberOfRectangles);

            var results = rectangleBuilder.GenerateOutputRectangles(generatedRectanglesInputList, yCoordinates);

            Assert.AreEqual(numberOfRectangles, results.Count);
        }