コード例 #1
0
        public void Able_to_get_the_width_and_height_of_a_complex_polygon()
        {
            // Given
            UniqueFractalPolygon polygon = new UniqueFractalPolygon();

            PointCollection points = polygon.DrawablePoints;

            // modify the fractal shape so that we know what the centre point will be
            points.Add(new System.Windows.Point(-20, 50));
            points.Add(new System.Windows.Point(220, -70));

            // When
            System.Windows.Point widthAndHeight = polygon.GetWidthAndHeight(points);

            // Then
            var expectedWidth = 240.0;
            var actualWidth   = widthAndHeight.X;

            Assert.AreEqual(expectedWidth, actualWidth);

            var expectedHeight = 120.0;
            var actualHeight   = widthAndHeight.Y;

            Assert.AreEqual(expectedHeight, actualHeight);
        }
コード例 #2
0
        public void Able_to_get_the_width_and_height_of_that_is_centred_on_a_positive_location_and_not_origin()
        {
            // Given
            UniqueFractalPolygon polygon = new UniqueFractalPolygon();

            // centred on (+10, +10)
            PointCollection pointsPositiveOffsetFromCentre = new PointCollection();

            pointsPositiveOffsetFromCentre.Add(new System.Windows.Point(11, 9));
            pointsPositiveOffsetFromCentre.Add(new System.Windows.Point(9, 9));
            pointsPositiveOffsetFromCentre.Add(new System.Windows.Point(9, 11));
            pointsPositiveOffsetFromCentre.Add(new System.Windows.Point(11, 11));

            // When

            System.Windows.Point widthAndHeight = polygon.GetWidthAndHeight(pointsPositiveOffsetFromCentre);

            // Then
            var expectedWidth = 2.0;
            var actualWidth   = widthAndHeight.X;

            Assert.AreEqual(expectedWidth, actualWidth);

            var expectedHeight = 2.0;
            var actualHeight   = widthAndHeight.Y;

            Assert.AreEqual(expectedHeight, actualHeight);
        }
コード例 #3
0
        public void Able_to_get_the_width_and_height_of_a_square()
        {
            // Given
            UniqueFractalPolygon polygon = new UniqueFractalPolygon();

            // When
            PointCollection points = new PointCollection();

            points.Add(new System.Windows.Point(0, 0));
            points.Add(new System.Windows.Point(0, 1));
            points.Add(new System.Windows.Point(1, 1));
            points.Add(new System.Windows.Point(1, 0));
            System.Windows.Point centrePoint = polygon.GetWidthAndHeight(points);

            // Then
            var expectedX = 1.0;

            Assert.AreEqual(expectedX, centrePoint.X);

            var expectedY = 1.0;

            Assert.AreEqual(expectedY, centrePoint.Y);
        }