public void ResetBoardShouldResetGameStateToPlaying() { //Arrange var game = new MineSweeperGame(3, 3, 0, new ServiceBus()); //Act game.ClickCoordinate(); game.ResetBoard(); //Assert Assert.AreEqual(GameState.Playing, game.State); }
/// <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); }
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)); } } }