public void KeyDownNow() { var listener = new GtUserActionsListener(); KeyboardState keyboardState = new KeyboardState(Keys.Escape);; GamePadState gamePadState = new GamePadState( new GamePadThumbSticks(), new GamePadTriggers(), new GamePadButtons(Buttons.A), new GamePadDPad()); listener.Update(keyboardState, gamePadState); Assert.IsTrue(listener.IsKeyDownNow(Keys.Escape)); Assert.IsFalse(listener.IsKeyDownNow(Keys.Enter)); Assert.IsTrue(listener.IsButtonDownNow(Buttons.A)); Assert.IsFalse(listener.IsButtonDownNow(Buttons.B)); //Update again with the same key pressed listener.Update(keyboardState, gamePadState); Assert.IsFalse(listener.IsKeyDownNow(Keys.Escape)); Assert.IsFalse(listener.IsKeyDownNow(Keys.Enter)); Assert.IsFalse(listener.IsButtonDownNow(Buttons.A)); Assert.IsFalse(listener.IsButtonDownNow(Buttons.B)); }
public void SelectTheThirdSong_GamePad() { KeyboardState keyboardState = new KeyboardState(); GamePadState gamePadState = new GamePadState( new GamePadThumbSticks(), new GamePadTriggers(), new GamePadButtons(), new GamePadDPad(ButtonState.Released, ButtonState.Pressed, ButtonState.Released, ButtonState.Released)); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); //this update will be called by the XNA Game class. var gameController = new GtGameControllerDouble(new GtFileLoaderDouble6(), EnumGameScreen.ChooseSong); gameController.LoadSongList(); Assert.AreSame(gameController.SongList[0], gameController.SelectedSong); gameController.Update(user1ActionListener); gameController.Update(user1ActionListener); Assert.AreSame(gameController.SongList[2], gameController.SelectedSong); }
public void VisibleSongsWindow_LastSelected() { KeyboardState keyboardState = new KeyboardState(Keys.Down); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); using (var gameController = new GtGameControllerDouble(new GtFileLoaderDouble100(), EnumGameScreen.ChooseSong)) { gameController.LoadSongList(); for (int i = 0; i < gameController.SongList.Count - 1; i++) { gameController.Update(user1ActionListener); } Assert.AreSame(gameController.SongList[gameController.SongList.Count - 1], gameController.SelectedSong); Assert.AreEqual(GtGameController.VISIBLE_SONG_WINDOW_SIZE, gameController.VisibleSongs.Count); for (int i = 0; i < GtGameController.VISIBLE_SONG_WINDOW_SIZE; i++) { Assert.AreSame( gameController.SongList[ gameController.SongList.Count - GtGameController.VISIBLE_SONG_WINDOW_SIZE + i], gameController.VisibleSongs[i]); } } }
public void EscapeFinishGameRound() { var player1 = new GtUserActionsListener(); var factory = new GtFactory(); factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>(); var controller = new GtGameRoundController( factory, new GtGameController(new GtFileLoaderDouble6())); controller.Update(player1); controller.GameRoundState = EnumGameRoundState.Playing; KeyboardState keyboardState = new KeyboardState(Keys.Escape);; GamePadState gamePadState = new GamePadState(); player1.Update(keyboardState, gamePadState); controller.Update(player1); Assert.AreEqual(EnumGameRoundState.Finished, controller.GameRoundState); }
public void EnterKeyIsResetedAfterUsed() { KeyboardState keyboardState = new KeyboardState(Keys.Enter); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); //this update will be called by the XNA Game class. var gameController = new GtGameControllerDouble(new GtFileLoaderDouble6(), EnumGameScreen.Main); user1ActionListener.Update(keyboardState, gamePadState); gameController.Update(user1ActionListener); Assert.AreEqual(EnumGameScreen.Menu, gameController.CurrentScreen); user1ActionListener.Update(keyboardState, gamePadState); gameController.Update(user1ActionListener); //here the Enter must be discarted Assert.AreEqual(EnumGameScreen.Menu, gameController.CurrentScreen); }
public void SelectTheThirdSong_Keyboard_WithBack() { var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(new KeyboardState(Keys.Down), new GamePadState()); //this update will be called by the XNA Game class. using (var gameController = new GtGameControllerDouble(new GtFileLoaderDouble6(), EnumGameScreen.ChooseSong)) { gameController.LoadSongList(); Assert.AreSame(gameController.SongList[0], gameController.SelectedSong); gameController.Update(user1ActionListener); gameController.Update(user1ActionListener); gameController.Update(user1ActionListener); user1ActionListener.Update(new KeyboardState(Keys.Up), new GamePadState()); gameController.Update(user1ActionListener); Assert.AreSame(gameController.SongList[2], gameController.SelectedSong); } }
public void FinishedToMenu_Keyboard() { var gameController = new GtGameControllerDouble(new GtFileLoaderDouble6(), EnumGameScreen.PlayingSong); gameController.GameRoundController.ForceGameRoundState(EnumGameRoundState.Finished); KeyboardState keyboardState = new KeyboardState(Keys.Escape); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); gameController.Update(user1ActionListener); Assert.AreEqual(EnumGameScreen.ChooseSong, gameController.CurrentScreen); }
public void GoToPlayingSongScreen_NoSelectedSong() { var gameController = new GtGameControllerDouble(new GtFileLoaderDouble0(), EnumGameScreen.ChooseSong); gameController.LoadSongList(); KeyboardState keyboardState = new KeyboardState(Keys.Enter); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); gameController.Update(user1ActionListener); Assert.AreEqual(EnumGameScreen.ChooseSong, gameController.CurrentScreen); }
public void NoKeyOrButton_NoScreenChange(EnumGameScreen pGameScreen) { KeyboardState keyboardState = new KeyboardState(); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); using (var gameController = new GtGameControllerDouble(pGameScreen)) { gameController.Update(user1ActionListener); Assert.AreEqual(pGameScreen, gameController.CurrentScreen); } }
public void UpdateMethod() { var listener = new GtUserActionsListener(); KeyboardState keyboardState = new KeyboardState(Keys.Escape);; GamePadState gamePadState = new GamePadState( new GamePadThumbSticks(), new GamePadTriggers(), new GamePadButtons(Buttons.B), new GamePadDPad()); listener.Update(keyboardState, gamePadState); Assert.AreEqual(keyboardState, listener.CurrentKeyboardState); Assert.AreEqual(gamePadState, listener.CurrentGamePadState); }
public void MenuSelection_SecondItemIsTune(Keys pKey, EnumMenuScreenItems pCurrentItem, EnumMenuScreenItems pExpectedItem) { var keyboardState = new KeyboardState(pKey); var gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); //this update will be called by the XNA Game class. using (var gameController = new GtGameControllerDouble(EnumGameScreen.Menu, pCurrentItem)) { gameController.Update(user1ActionListener); Assert.AreEqual(EnumGameScreen.Menu, gameController.CurrentScreen); Assert.AreEqual(pExpectedItem, gameController.MenuScreenSelectedItem); } }
public void MenuSelection_QuickPlayIsTheDefault() { KeyboardState keyboardState = new KeyboardState(Keys.Enter); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); //this update will be called by the XNA Game class. using (var gameController = new GtGameControllerDouble(EnumGameScreen.Main)) { gameController.Update(user1ActionListener); Assert.AreEqual(EnumGameScreen.Menu, gameController.CurrentScreen); Assert.AreEqual(EnumMenuScreenItems.QuickPlay, gameController.MenuScreenSelectedItem); } }
public void ScreenChangesUsingKeyboard(EnumGameScreen pCurrentScreen, EnumMenuScreenItems pMenuItem, Keys pKey, EnumGameScreen pExpectedScreen, EnumMenuScreenItems pExpectedMenuItem) { KeyboardState keyboardState = new KeyboardState(pKey); GamePadState gamePadState = new GamePadState(); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); //this update will be called by the XNA Game class. using (var gameController = new GtGameControllerDouble(pCurrentScreen, pMenuItem)) { gameController.Update(user1ActionListener); Assert.AreEqual(pExpectedScreen, gameController.CurrentScreen); Assert.AreEqual(pExpectedMenuItem, gameController.MenuScreenSelectedItem); } }
public void GoToPlayingSongScreenForTheSelectedSong_GamePad() { var gameController = new GtGameControllerDouble(new GtFileLoaderDouble6(), EnumGameScreen.ChooseSong); gameController.LoadSongList(); KeyboardState keyboardState = new KeyboardState(); GamePadState gamePadState = new GamePadState( new GamePadThumbSticks(), new GamePadTriggers(), new GamePadButtons(Buttons.A), new GamePadDPad()); var user1ActionListener = new GtUserActionsListener(); user1ActionListener.Update(keyboardState, gamePadState); gameController.Update(user1ActionListener); Assert.AreEqual(EnumGameScreen.PlayingSong, gameController.CurrentScreen); Assert.AreEqual(EnumGameRoundState.Playing, gameController.GameRoundController.GameRoundState); }
public void RightArrowDecreaseVelocityByPointOne(decimal initialVelocityValue, decimal finalVelocityValue) { var player1 = new GtUserActionsListener(); var factory = new GtFactory(); factory.AddMapping <IAudioListener, DoubleAudioListenerDoNothing>(); var controller = new GtGameRoundController( factory, new GtGameController(new GtFileLoaderDouble6())); KeyboardState keyboardState = new KeyboardState(Keys.Right);; GamePadState gamePadState = new GamePadState(); player1.Update(keyboardState, gamePadState); controller.VelocityValue = initialVelocityValue; controller.Update(player1); Assert.AreEqual(finalVelocityValue, controller.VelocityValue); }