public void ComputerGeneratesExpectedMoves()
        {
            // Check computer generates all possible moves, with reasonably equal distribution
            int rockCount = 0, paperCount = 0, scissorsCount = 0;

            int gameCount = 1000;
            for( int gameNumber = 0; gameNumber < gameCount; gameNumber++)
            {
                IPlayer player = new ComputerPlayer();

                switch (player.Move)
                {
                    case Move.Paper:
                        paperCount++;
                        break;
                    case Move.Rock:
                        rockCount++;
                        break;
                    case Move.Scissors:
                        scissorsCount++;
                        break;
                }
            }

            Assert.IsTrue(paperCount > 0, "Computer generation of paper count is zero");
            Assert.IsTrue(rockCount > 0, "Computer generation of rock count is zero");
            Assert.IsTrue(scissorsCount > 0, "Computer generation of scissors count is zero");

            // We expect roughly equal distribution of moves between available choices
            // Testing for at least half of that expected distribution avoids variance causing this test to fail
            int minimalExpectedCountEachMove = gameCount / 6;

            Assert.IsTrue(paperCount > minimalExpectedCountEachMove, "Computer generation of paper count is zero");
            Assert.IsTrue(rockCount > minimalExpectedCountEachMove, "Computer generation of rock count is zero");
            Assert.IsTrue(scissorsCount > minimalExpectedCountEachMove, "Computer generation of scissors count is zero");
        }
        public ActionResult Index(GameModel gameModel)
        {
            gameModel.GameResult = string.Empty;
            IPlayer player1 = null;
            IPlayer player2 = null;

            string playerChoices = string.Empty;

            // Set Player1
            if ( gameModel.Player1Move == PlayerMoveChoices.computer)
            {
                player1 = new ComputerPlayer();
            }
            else
            {
                player1 = new HumanPlayer();

                switch(gameModel.Player1Move)
                {
                    case PlayerMoveChoices.paper:
                        player1.Move = Move.Paper;
                        break;
                    case PlayerMoveChoices.scissors:
                        player1.Move = Move.Scissors;
                        break;
                    case PlayerMoveChoices.rock:
                        player1.Move = Move.Rock;
                        break;
                }
            }

            // Set Player2
            if (gameModel.Player2Move == PlayerMoveChoices.computer)
            {
                player2 = new ComputerPlayer();
            }
            else
            {
                throw new ApplicationException();
            }

            IGame game = new Game(player1, player2);
            GameResult gameResult = game.DecideWinner();

            string playerChoicesDescription = " (" + player1.Move.ToString() + "/" + player2.Move.ToString() + ")";

            switch(gameResult)
            {
                case GameResult.Draw:
                    gameModel.GameResult = "Draw " + playerChoicesDescription;
                    break;
                case GameResult.Player1Wins:
                    gameModel.GameResult = "Player 1 won " + playerChoicesDescription;
                    break;
                case GameResult.Player2Wins:
                    gameModel.GameResult = "Player 2 won " + playerChoicesDescription;
                    break;
            }

            return View(gameModel);
        }