public void MoveCursorUpShouldMoveUp() { //Arrange via Setup //Act _underTest.MoveCursorDown(); _underTest.MoveCursorDown(); _underTest.MoveCursorUp(); //Assert Assert.AreEqual(1, _underTest.PosY); }
/// <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 DrawBoardShouldDrawSymbolFor8Neighbours() { //Arrange var bus = A.Fake <IServiceBus>(); A.CallTo(() => bus.Next(A <int> .Ignored)).ReturnsNextFromSequence(0, 0, 1, 0, 2, 0, 0, 1, 2, 1, 0, 2, 1, 2, 2, 2); var game = new MineSweeperGame(3, 3, 8, bus); //Act game.MoveCursorRight(); game.MoveCursorDown(); game.ClickCoordinate(); game.MoveCursorUp(); game.DrawBoard(); //Assert A.CallTo(() => bus.Write("8 ")).MustHaveHappened(Repeated.Exactly.Once); }