public void ClickCoordinateShouldOpenBoardCoordinate()
 {
     //Arrange via Setup
     //Act
     _underTest.ClickCoordinate();
     //Assert
     Assert.AreEqual(true, _underTest.GetCoordinate(0, 0).IsOpen);
 }
        public void FlagCoordinateShouldFlagNonOpenCoordinate()
        {
            //Arrange via setup
            //Act
            _underTest.FlagCoordinate();
            var coord = _underTest.GetCoordinate(0, 0);

            //Assert
            Assert.AreEqual(coord.IsFlagged, true);
        }
        public void ResetBoardShouldCalaculateNeighbouringNrOfMinesLargerThan1()
        {
            //Arrange & assume
            IServiceBus bus = A.Fake <IServiceBus>();

            A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(1, 1, 2, 2);
            var game = new MineSweeperGame(3, 3, 2, bus);

            //Act
            var coord1 = game.GetCoordinate(2, 1);
            var coord2 = game.GetCoordinate(1, 2);

            //Assert
            Assert.AreEqual(2, coord1.NrOfNeighbours);
            Assert.AreEqual(2, coord2.NrOfNeighbours);
        }
        public void ClickCoordinateShouldOnlyOpenOneCoordinateEastOfMine()
        {
            //Arrange
            var bus = A.Fake <IServiceBus>();

            A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(2, 2);
            var game      = new MineSweeperGame(5, 5, 1, bus);
            int openCount = 0;

            //Act
            game.MoveCursorRight();
            game.MoveCursorRight();
            game.MoveCursorRight();
            game.MoveCursorDown();
            game.MoveCursorDown();
            game.ClickCoordinate();
            //Assert
            for (int y = 0; y < game.SizeY; y++)
            {
                for (int x = 0; x < game.SizeX; x++)
                {
                    if (game.GetCoordinate(x, y).IsOpen)
                    {
                        openCount++;
                    }
                }
            }
            Assert.AreEqual(1, openCount);
        }
 public void GetCoordinateShouldThrowExceptionForNegativeX()
 {
     //Arrange via setup
     //Act
     _underTest.GetCoordinate(-1, 0);
     //Assert via Exception & method attribute
 }
示例#6
0
        public void ConstructorShouldCallResetBoard()
        {
            //Arrange
            var game = new MineSweeperGame(5, 6, 10, new ServiceBus());

            //Act
            var coord = game.GetCoordinate(3, 3);

            //Assert
            Assert.IsNotNull(coord);
        }
        public void ResetBoardShouldCalculate1Neighbours()
        {
            //Arrange
            var bus = A.Fake <IServiceBus>();

            A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(0, 0);

            //Act
            var game       = new MineSweeperGame(3, 3, 1, bus);
            var coordinate = game.GetCoordinate(1, 1);

            //Assert
            Assert.AreEqual(1, coordinate.NrOfNeighbours);
        }
        public void ClickCoordinateShouldUsePosXAndPosY()
        {
            //Arrange
            var bus = A.Fake <IServiceBus>();

            A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(0, 0);
            var game = new MineSweeperGame(2, 2, 1, bus);

            //Act
            game.MoveCursorRight();
            game.MoveCursorDown();
            game.ClickCoordinate();
            //Assert
            Assert.AreEqual(true, game.GetCoordinate(1, 1).IsOpen);
        }
        public void ClickCoordinateShouldOpenNeighbourPositions()
        {
            //Arrange
            var bus = A.Fake <IServiceBus>();

            A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(2, 2);
            var game = new MineSweeperGame(5, 5, 1, bus);

            //Act
            game.ClickCoordinate();
            var coord = game.GetCoordinate(1, 2);

            //Assert
            Assert.AreEqual(true, coord.IsOpen);
        }
        public void ClickCoordinateShouldOpenAllMineCoordinatesIfMineHit()
        {
            //Arrange
            var bus = A.Fake <IServiceBus>();

            A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(1, 1, 0, 0);
            var game = new MineSweeperGame(2, 2, 2, bus);

            //Act
            game.ClickCoordinate();
            var coord = game.GetCoordinate(1, 1);

            //Assert
            Assert.AreEqual(true, coord.IsOpen);
        }
示例#11
0
        public void ResetBoardShouldCreatePositionInfoForAllBoardPositions()
        {
            //Arrange via Setup

            //Act
            _underTest.ResetBoard();

            //Assert
            Assert.IsNotNull(_underTest.GetCoordinate(0, 0));

            for (int y = 0; y < _underTest.SizeY; y++)
            {
                for (int x = 0; x < _underTest.SizeX; x++)
                {
                    Assert.IsInstanceOfType(_underTest.GetCoordinate(x, y), typeof(PositionInfo));
                }
            }
        }