예제 #1
0
        public ActionResult PlayAgain()
        {
            List <RockPaperScissorsGame> allGames    = RockPaperScissorsGame.GetAll();
            RockPaperScissorsGame        currentGame = allGames[0];

            return(View("PlayerOneSelection", currentGame));
        }
        public void ConvertPlayerChoiceToNumber_ConvertsPaperStringToZero_Zero()
        {
            int    paperInt     = 0;
            string playerChoice = "Paper";
            int    answer       = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerChoice);

            Assert.AreEqual(paperInt, answer);
        }
        public void ConvertPlayerChoiceToNumber_ConvertsScissorsStringToOne_One()
        {
            int    scissorsInt  = 1;
            string playerChoice = "Scissors";
            int    answer       = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerChoice);

            Assert.AreEqual(scissorsInt, answer);
        }
        public void Battle_PaperAndRock_PlayerOneWon()
        {
            var game = new RockPaperScissorsGame();

            var actual = game.Battle(Gesture.Paper, Gesture.Rock);

            actual.Should().Be(GameResult.PlayerOneWon);
        }
        public void ConvertPlayerChoiceToNumber_ConvertsInvalidChoiceSting_NegativeOne()
        {
            int    invalidChoice = -1;
            string playerChoice  = "Rck";
            int    answer        = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerChoice);

            Assert.AreEqual(invalidChoice, answer);
        }
예제 #6
0
        public ActionResult PlayAgainComputer()
        {
            List <RockPaperScissorsGame> allGames    = RockPaperScissorsGame.GetAll();
            RockPaperScissorsGame        currentGame = allGames[0];

            currentGame.Computery();
            return(View("Computer", currentGame));
        }
        public void Battle_RockAndSicssors_PlayerOneWon()
        {
            var game = new RockPaperScissorsGame();

            var actual = game.Battle(Gesture.Rock, Gesture.Scissors);

            actual.Should().Be(GameResult.PlayerOneWon);
        }
예제 #8
0
        public ActionResult PlayerOneSelection()
        {
            string PlayerOneName          = Request.Form["player-one"];
            string PlayerTwoName          = Request.Form["player-two"];
            RockPaperScissorsGame newGame = new RockPaperScissorsGame(PlayerOneName, PlayerTwoName);

            return(View(newGame));
        }
예제 #9
0
 public RockPaperScissorsEndGame(int intervalInSeconds,
                                 RockPaperScissorsGame rockPaperScissorsGame,
                                 IChatClient chatClient)
 {
     _rockPaperScissorsGame = rockPaperScissorsGame;
     _chatClient            = chatClient;
     _timeOfNextRun         = DateTime.Now.AddSeconds(intervalInSeconds);
 }
        public void Battle_ScissorsAndScissors_Tie()
        {
            var game = new RockPaperScissorsGame();

            var actual = game.Battle(Gesture.Scissors, Gesture.Scissors);

            actual.Should().Be(GameResult.Tie);
        }
        public void Battle_PaperAndPaper_Tien()
        {
            var game = new RockPaperScissorsGame();

            var actual = game.Battle(Gesture.Paper, Gesture.Paper);

            actual.Should().Be(GameResult.Tie);
        }
        public void Battle_RockAndRock_Tie()
        {
            var game = new RockPaperScissorsGame();

            var actual = game.Battle(Gesture.Rock, Gesture.Rock);

            actual.Should().Be(GameResult.Tie);
        }
        public void ConvertPlayerChoiceToNumber_ConvertsRockStringToTwo_Two()
        {
            int    rockInt      = 2;
            string playerChoice = "Rock";
            int    answer       = RockPaperScissorsGame.ConvertPlayerChoiceToNumber(playerChoice);

            Assert.AreEqual(rockInt, answer);
        }
예제 #14
0
        public ActionResult Computer()
        {
            string PlayerOneName          = Request.Form["player-one-computer"];
            string PlayerTwoName          = "Computer";
            RockPaperScissorsGame newGame = new RockPaperScissorsGame(PlayerOneName, PlayerTwoName);

            newGame.Computery();
            return(View(newGame));
        }
        public void GameResult_ReturnsStringDrawAsDefaultInt_Zero()
        {
            int playerOneChoice = 2;
            int playerTwoChoice = 2;
            int draw            = 0;
            int answer          = RockPaperScissorsGame.GameResult(playerOneChoice, playerTwoChoice);

            Assert.AreEqual(draw, answer);
        }
        public void GameResult_ReturnsIntTwoWhenPlayerTwosChoiceIsGreaterThanPlayerOnesChoice_Two()
        {
            int playerOneChoice = 1;
            int playerTwoChoice = 2;
            int two             = 2;
            int answer          = RockPaperScissorsGame.GameResult(playerOneChoice, playerTwoChoice);

            Assert.AreEqual(two, answer);
        }
        public void GameResult_ReturnIntOneIfPlayerOnesChoiceEqualsZeroAndPlayerTwosChoiceEqualsIntTwo_One()
        {
            int playerOneChoice = 0;
            int playerTwoChoice = 2;
            int one             = 1;
            int answer          = RockPaperScissorsGame.GameResult(playerOneChoice, playerTwoChoice);

            Assert.AreEqual(one, answer);
        }
        public void GameResult_ReturnsIntTwoIfPlayerTwosChoiceEqualsIntZeroAndPlayerOnesChoiceEqulsIntTwo_Two()
        {
            int playerOneChoice = 2;
            int playerTwoChoice = 0;
            int two             = 2;
            int answer          = RockPaperScissorsGame.GameResult(playerOneChoice, playerTwoChoice);

            Assert.AreEqual(two, answer);
        }
예제 #19
0
        public ActionResult ComputerResults()
        {
            string PlayerOneSelection                = Request.Form["player-one-selection-computer"];
            List <RockPaperScissorsGame> allGames    = RockPaperScissorsGame.GetAll();
            RockPaperScissorsGame        currentGame = allGames[0];

            currentGame.SetPlayerOneChoice(PlayerOneSelection);
            currentGame.GameResult();
            return(View(currentGame));
        }
예제 #20
0
        public void GetChoice_FetchPlayerTwoChoice_String()
        {
            //arrange
            RockPaperScissorsGame newGame = new RockPaperScissorsGame("Player 1", "Player 2");
            //act
            string result = newGame.GetPlayerTwoChoice();

            //assert
            Assert.AreEqual("", result);
        }
예제 #21
0
        public void GetDraws_FetchDraws_int()
        {
            //arrange
            RockPaperScissorsGame newGame = new RockPaperScissorsGame("Player 1", "Player 2");
            //act
            int result = newGame.GetDraws();

            //assert
            Assert.AreEqual(0, result);
        }
예제 #22
0
        public static BotMain NewBot(TwitchClientSettings twitchSettings, string connectionString)
        {
            var twitchApi        = new TwitchAPI(twitchSettings.TwitchClientId);
            var twitchChatClient = new TwitchChatClient(twitchSettings, twitchApi);
            var chatClients      = new List <IChatClient>
            {
                new ConsoleChatClient(),
                twitchChatClient,
            };
            var twitchFollowerService = new TwitchFollowerService(twitchApi, twitchSettings);

            IRepository repository = SetUpDatabase.SetUpRepository(connectionString);

            var chatUserCollection = new ChatUserCollection(repository);
            var currencyGenerator  = new CurrencyGenerator(chatClients, chatUserCollection);
            var currencyUpdate     = new CurrencyUpdate(1, currencyGenerator);

            var automatedActionSystem = new AutomatedActionSystem(new List <IIntervalAction> {
                currencyUpdate
            });
            var rockPaperScissorsGame = new RockPaperScissorsGame(currencyGenerator, automatedActionSystem);
            var wordList = new List <string> {
                "apple", "banana", "orange", "mango", "watermellon", "grapes", "pizza", "pasta", "pepperoni", "cheese", "mushroom", "csharp", "javascript", "cplusplus", "nullreferenceexception", "parameter", "argument"
            };
            var hangmanGame = new HangmanGame(currencyGenerator, automatedActionSystem, wordList);

            var simpleCommands = repository.List <SimpleCommand>();

            List <IBotCommand> allCommands = new List <IBotCommand>();

            allCommands.AddRange(simpleCommands);
            allCommands.Add(new GiveCommand(chatUserCollection));
            allCommands.Add(new HelpCommand(allCommands));
            allCommands.Add(new CommandsCommand(allCommands));
            allCommands.Add(new CoinsCommand(repository));
            allCommands.Add(new BonusCommand(currencyGenerator));
            allCommands.Add(new StreamsCommand(repository));
            allCommands.Add(new ShoutOutCommand(twitchFollowerService));
            allCommands.Add(new QuoteCommand(repository));
            allCommands.Add(new AddQuoteCommand(repository));
            allCommands.Add(new AddCommandCommand(repository, allCommands));
            allCommands.Add(new RemoveCommandCommand(repository, allCommands));
            allCommands.Add(new HangmanCommand(hangmanGame));
            allCommands.Add(new RockPaperScissorsCommand(rockPaperScissorsGame));

            var commandHandler    = new CommandHandler(chatClients, allCommands);
            var subscriberHandler = new SubscriberHandler(chatClients);

            var twitchSystem = new FollowableSystem(new[] { twitchChatClient }, twitchFollowerService);


            var botMain = new BotMain(chatClients, repository, commandHandler, subscriberHandler, twitchSystem, automatedActionSystem);

            return(botMain);
        }
예제 #23
0
        public void ScissorsAlwaysDrawsScissors()
        {
            IPlayer player1 = new ScissorsPlayer();
            IPlayer player2 = new ScissorsPlayer();

            RockPaperScissorsGame game = new RockPaperScissorsGame(player1, player2);

            Outcome result = game.Play();

            Assert.AreEqual(Outcome.Draw, result);
        }
예제 #24
0
        public void PaperAlwaysBeatsRock()
        {
            IPlayer player1 = new PaperPlayer();
            IPlayer player2 = new RockPlayer();

            RockPaperScissorsGame game = new RockPaperScissorsGame(player1, player2);

            Outcome result = game.Play();

            Assert.AreEqual(Outcome.Player1Wins, result);
        }
예제 #25
0
        public ActionResult Results()
        {
            string PlayerTwoSelection                = Request.Form["player-two-selection"];
            List <RockPaperScissorsGame> allGames    = RockPaperScissorsGame.GetAll();
            RockPaperScissorsGame        currentGame = allGames[0];

            currentGame.SetPlayerTwoChoice(PlayerTwoSelection);
            currentGame.GameResult();

            return(View(currentGame));
        }
예제 #26
0
        public void SetName_SetPlayerOneChoice_void()
        {
            //arrange
            string choice = "Paper";
            RockPaperScissorsGame newGame = new RockPaperScissorsGame("Player 1", "Player 2");

            //act
            newGame.SetPlayerOneChoice(choice);
            //assert
            Assert.AreEqual("Paper", newGame.GetPlayerOneChoice());
        }
예제 #27
0
        public void SetName_SetPlayerTwoName_void()
        {
            //arrange
            string name = "Joel";
            RockPaperScissorsGame newGame = new RockPaperScissorsGame("Player 1", "Player 2");

            //act
            newGame.SetPlayerTwoName(name);
            //assert
            Assert.AreEqual("Joel", newGame.GetPlayerTwoName());
        }
예제 #28
0
        public void Getters_PlayerOneNameAndGameWinner_String()
        {
            //arrange
            RockPaperScissorsGame newGame = new RockPaperScissorsGame("Player 1", "Player 2");
            //act
            string result           = newGame.GetPlayerOneName();
            string gameWinnerResult = newGame.GetGameWinner();

            //assert
            Assert.AreEqual("Player 1", result);
            Assert.AreEqual(" ", gameWinnerResult);
        }
예제 #29
0
        public void GameWinCheck_DetermineWinnerOrDraw_int()
        {
            //arrange
            RockPaperScissorsGame newGame = new RockPaperScissorsGame("Player 1", "Player 2");

            //act
            newGame.SetPlayerOneChoice("Rock");
            newGame.SetPlayerTwoChoice("Scissors");
            int result = newGame.GameWinCheck();

            //assert
            Assert.AreEqual(1, result);
        }
예제 #30
0
        public void PlayAgain_HasCorrectModelType_RPSGame()
        {
            //arrange
            RockPaperScissorsGame dummyGame     = new RockPaperScissorsGame("PlayerOneName", "PlayerTwoName");
            ViewResult            playAgainView = new HomeController().PlayAgain() as ViewResult;
            //act
            var result = playAgainView.ViewData.Model;

            System.Console.WriteLine("play again result: " + result);

            //assert
            Assert.IsInstanceOfType(result, typeof(RockPaperScissorsGame));
        }
예제 #31
0
 public RockPaperScissorsController(RockPaperScissorsGame game)
 {
     _game = game;
 }