コード例 #1
0
        public void Resizing_and_moving_sets_the_height_and_width()
        {
            // Given
            CreateMockFactory();
            _mockUniqueFractalPolygon.Setup(m => m.SetOutlineWidth(It.IsAny <double>()));

            // centred square
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, -1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, -1));

            Color unused      = Color.FromRgb(1, 2, 3);
            var   islandShape = new IslandShape(unused);

            // When
            var islandSize     = 1.0;                                // no resize
            var islandLocation = new System.Windows.Point(-10, -10); // arbitrary

            islandShape.ResizeAndMove(islandSize, islandLocation);

            // Then
            var expectedWidthAndHeight = new System.Windows.Point(2, 2);
            var actualWidth            = islandShape.Width;

            Assert.AreEqual(expectedWidthAndHeight.X, actualWidth);

            var actualHeight = islandShape.Height;

            Assert.AreEqual(expectedWidthAndHeight.Y, actualHeight);
        }
コード例 #2
0
        public void Resizing_and_moving_sets_the_centre_point()
        {
            // Given
            CreateMockFactory();
            _mockUniqueFractalPolygon.Setup(m => m.SetOutlineWidth(It.IsAny <double>()));

            // centred square
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, -1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, -1));

            Color unused      = Color.FromRgb(1, 2, 3);
            var   islandShape = new IslandShape(unused);

            // When
            var islandSize     = 5.0;                                // arbitrary
            var islandLocation = new System.Windows.Point(-10, -10); // arbitrary

            islandShape.ResizeAndMove(islandSize, islandLocation);

            // Then
            var expectedCentrePoint = islandLocation;
            var actualCentrePoint   = islandShape.CentrePoint;

            Assert.AreEqual(expectedCentrePoint, actualCentrePoint);
        }
コード例 #3
0
        public void Moving_for_the_first_time_in_a_positive_location_relocates_the_shape()
        {
            // Given
            CreateMockFactory();
            _mockUniqueFractalPolygon.Setup(m => m.SetOutlineWidth(It.IsAny <double>()));

            // centred square
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, -1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, -1));

            Color unused      = Color.FromRgb(1, 2, 3);
            var   islandShape = new IslandShape(unused);

            // When
            var pointsBeforeResizeAndMove = new PointCollection(_mockPolygonPoints);

            var islandSize     = 1.0;                              // no resizing
            var islandLocation = new System.Windows.Point(10, 10); // not origin

            islandShape.ResizeAndMove(islandSize, islandLocation);

            // Then
            var expectedCentrePoint = islandLocation;
            var actualCentrePoint   = TestHelper_GetCentrePoint(_mockPolygonPoints);

            Assert.AreEqual(expectedCentrePoint, actualCentrePoint);
        }
コード例 #4
0
        public void Resizing_and_moving_for_the_first_time_in_a_negative_location_relocates_the_shape_by_the_given_size()
        {
            // Given
            CreateMockFactory();
            _mockUniqueFractalPolygon.Setup(m => m.SetOutlineWidth(It.IsAny <double>()));

            // centred square
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, 1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(1, -1));
            _mockUniqueFractalPolygonPoints.Add(new System.Windows.Point(-1, -1));

            Color unused      = Color.FromRgb(1, 2, 3);
            var   islandShape = new IslandShape(unused);

            // When
            var widthBeforeResizeAndMove  = 2;
            var heightBeforeResizeAndMove = 2;
            var pointsBeforeResizeAndMove = new PointCollection(_mockPolygonPoints);

            var islandSize     = 5.0;
            var islandLocation = new System.Windows.Point(-10, -10);  // not origin

            islandShape.ResizeAndMove(islandSize, islandLocation);

            // Then
            var expectedCentrePoint = islandLocation;
            var actualCentrePoint   = TestHelper_GetCentrePoint(_mockPolygonPoints);

            Assert.AreEqual(expectedCentrePoint, actualCentrePoint);

            var expectedWidth = widthBeforeResizeAndMove * islandSize;
            var actualWidth   = TestHelper_GetWidthAndHeight(_mockPolygonPoints).X;

            Assert.AreEqual(expectedWidth, actualWidth);

            var expectedHeight = heightBeforeResizeAndMove * islandSize;
            var actualHeight   = TestHelper_GetWidthAndHeight(_mockPolygonPoints).Y;

            Assert.AreEqual(expectedHeight, actualHeight);

            var expectedPoints = pointsBeforeResizeAndMove;
            var actualPoints   = _mockPolygonPoints;

            Assert.AreNotEqual(expectedPoints, actualPoints);
        }