コード例 #1
0
        public void GivenABlockOfColouredPixels_AndPixelPositionInBlockGivrn_ThenAdjacentPixelsAreReturned()
        {
            _colourGridService = new GridService(4, _startIndexPosition);
            var expectedColour = "red";

            _colourGridService.FillRow(expectedColour, 1, 1, 2);
            _colourGridService.FillRow(expectedColour, 2, 1, 2);

            var adjecent = _colourGridService.GetAllAdjacentSameColourPixels(new PixelPosition {
                X = 1, Y = 1
            });
            var grid        = _colourGridService.GetGridContent();
            var resultPixel = grid[1, 1];

            Assert.That(resultPixel.Colour, Is.EqualTo(expectedColour));
            var pixelPositions = adjecent as PixelPosition[] ?? adjecent.ToArray();

            Assert.That(pixelPositions.Count(), Is.EqualTo(4));
            Assert.That(pixelPositions.Any(p => p.X == 1 && p.Y == 1));
            Assert.That(pixelPositions.Any(p => p.X == 2 && p.Y == 1));
            Assert.That(pixelPositions.Any(p => p.X == 1 && p.Y == 2));
            Assert.That(pixelPositions.Any(p => p.X == 2 && p.Y == 2));
        }