public void MoveCursorLeftShouldMoveLeft() { //Arrange via Setup //Act _underTest.MoveCursorRight(); _underTest.MoveCursorRight(); _underTest.MoveCursorLeft(); //Assert Assert.AreEqual(1, _underTest.PosX); }
/// <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); }