예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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]);
                }
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
            }
        }
예제 #12
0
        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);
            }
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }