public void FlagCoordinateShouldFlagNonOpenCoordinate()
        {
            //Arrange via setup
            //Act
            _underTest.FlagCoordinate();
            var coord = _underTest.GetCoordinate(0, 0);

            //Assert
            Assert.AreEqual(coord.IsFlagged, true);
        }
 public void ClickCoordinateShouldNotOpenFlaggedBoardCoordinate()
 {
     //Arrange via Setup
     //Act
     _underTest.FlagCoordinate();
     _underTest.ClickCoordinate();
     //Assert
     Assert.AreEqual(false, _underTest.GetCoordinate(0, 0).IsOpen);
 }
Beispiel #3
0
        public void DrawBoardShouldDrawMarkedSymbolForFlag()
        {
            //Arrange
            var bus  = A.Fake <IServiceBus>();
            var game = new MineSweeperGame(2, 2, 0, bus);

            //Act
            game.FlagCoordinate();
            game.DrawBoard();
            //Assert
            A.CallTo(() => bus.Write("! ", ConsoleColor.DarkCyan)).MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #4
0
        public void DrawBoardShouldDrawSymbolForFlag()
        {
            //Arrange
            var bus  = A.Fake <IServiceBus>();
            var game = new MineSweeperGame(2, 2, 0, bus);

            //Act
            game.FlagCoordinate();
            game.MoveCursorRight();
            game.DrawBoard();
            //Assert
            A.CallTo(() => bus.Write("! ")).MustHaveHappened(Repeated.Exactly.Once);
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            KeyboardState kbState = Keyboard.GetState();

            if (gameLogic.State == GameState.Playing)
            {
                if (kbState.IsKeyDown(Keys.Left) && prevState.IsKeyUp(Keys.Left))
                {
                    gameLogic.MoveCursorLeft();
                }
                if (kbState.IsKeyDown(Keys.Right) && prevState.IsKeyUp(Keys.Right))
                {
                    gameLogic.MoveCursorRight();
                }
                if (kbState.IsKeyDown(Keys.Up) && prevState.IsKeyUp(Keys.Up))
                {
                    gameLogic.MoveCursorUp();
                }
                if (kbState.IsKeyDown(Keys.Down) && prevState.IsKeyUp(Keys.Down))
                {
                    gameLogic.MoveCursorDown();
                }
                if (kbState.IsKeyDown(Keys.Space) && prevState.IsKeyUp(Keys.Space))
                {
                    gameLogic.ClickCoordinate();
                }
                if (kbState.IsKeyDown(Keys.Enter) && prevState.IsKeyUp(Keys.Enter))
                {
                    gameLogic.FlagCoordinate();
                }
            }
            else
            {
                if (kbState.IsKeyDown(Keys.Space) && prevState.IsKeyUp(Keys.Space))
                {
                    gameLogic.ResetBoard();
                }
            }

            prevState = kbState;
            base.Update(gameTime);
        }