예제 #1
0
        public void Uncover_OnNoMine_ReturnsRightAmountOfAdjacentMines(MinefieldTestData testdata)
        {
            Minefield minefieldUnderTest = new(3, 3, 0, new MinelayerToTest(testdata.MineLocations));

            IGameUpdateReport result = minefieldUnderTest.Uncover(1, 1);

            result.Cells.Should().NotBeEmpty()
            .And.ContainSingle(cell => cell.AdjacentMineCount == testdata.MineLocations.Count);
        }
예제 #2
0
        public void MinefieldUncover_Should_ReturnAtLeastTheClickedLocation()
        {
            Minefield minefieldUnderTest = new(5, 7, 11, new RandomMinelayer(new GuidLocationShuffler()));
            Location  locationTestValue  = new(3, 4);

            IGameUpdateReport result = minefieldUnderTest.Uncover(locationTestValue);

            result.Cells.Should().NotBeEmpty()
            .And.ContainSingle(cell => cell.Location == locationTestValue);
        }
예제 #3
0
        public void Uncover_OnLastCellWithoutMine_ReturnsNoMineAndGameWon()
        {
            Location  mineLocation       = new(1, 0);
            Minefield minefieldUnderTest = new(2, 1, 1, new MinelayerToTest(mineLocation));

            IGameUpdateReport result = minefieldUnderTest.Uncover(0, 0);

            result.Cells.Should().NotBeEmpty()
            .And.ContainSingle(cell => !cell.IsMine);
            result.Status.Should().Be(GameStatus.IsWon);
        }
예제 #4
0
        public void Uncover_OnCellWithoutMine_GameStillInProgress()
        {
            Location  mineLocation       = new(1, 0);
            Minefield minefieldUnderTest = new(3, 1, 1, new MinelayerToTest(mineLocation));

            IGameUpdateReport result = minefieldUnderTest.Uncover(0, 0);

            result.Cells.Should().NotBeEmpty()
            .And.Contain(cell => !cell.IsMine);
            result.Status.Should().Be(GameStatus.InProgress);
        }
예제 #5
0
 internal GameUpdater WithReport(IGameUpdateReport report)
 {
     Report = report;
     return(this);
 }