示例#1
0
        static void Main(string[] args)
        {
            var armandoPlays  = new PlayerMove("Armando", "P");
            var davePlays     = new PlayerMove("Dave", "S");
            var richardPlays  = new PlayerMove("Richard", "R");
            var michaelPlays  = new PlayerMove("Michael", "S");
            var allenPlays    = new PlayerMove("Allen", "S");
            var omerPlays     = new PlayerMove("Omer", "P");
            var davidEPlays   = new PlayerMove("David E.", "R");
            var richardXPlays = new PlayerMove("Richard X.", "P");

            var champion = RockPaperScissor.rps_tournament_winner(new Tournament
            {
                LeftBracket = new List <IEnumerable <PlayerMove> > {
                    new List <PlayerMove> {
                        armandoPlays, davePlays
                    },
                    new List <PlayerMove> {
                        richardPlays, michaelPlays
                    }
                },
                RightBracket = new List <IEnumerable <PlayerMove> >
                {
                    new List <PlayerMove> {
                        allenPlays, omerPlays
                    },
                    new List <PlayerMove> {
                        davidEPlays, richardXPlays
                    }
                }
            });

            Console.WriteLine($"Congratulations to the Tournament Winner!!! --- {champion.Name.ToUpper()} ---");
        }
        public void ConvertPick_ReturnPickString()
        {
            int    userInput  = 1;
            string pickString = "Rock";

            string expectedResult = RockPaperScissor.ConvertPick(userInput);

            Assert.AreEqual(pickString, expectedResult);
        }
示例#3
0
        public void PlayerOneRock_PlayerOneWins_False()
        {
            RockPaperScissor newGame = new RockPaperScissor();

            newGame.PlayerOneRock("Paper");
            int POS = newGame.GetPlayerOneScore();

            Assert.AreEqual(POS, 0);
        }
        public void GetPick_ReturnUserPick()
        {
            int userInput = 1;
            RockPaperScissor playerOne = new RockPaperScissor(userInput);

            int expectedResult = playerOne.GetPick();

            Assert.AreEqual(userInput, expectedResult);
        }
示例#5
0
 public void RpsGameWinner_Should_Raise_NoSuchStrategyError()
 {
     Assert.ThrowsException <NoSuchStrategyError>(() =>
                                                  RockPaperScissor.rps_game_winner(
                                                      new List <PlayerMove> {
         new PlayerMove("ABC", "P"),
         new PlayerMove("ABCD", "e"),
     }));
 }
示例#6
0
        public void PlayerOneScissors_PlayerOneWins_True()
        {
            RockPaperScissor newGame = new RockPaperScissor();

            newGame.PlayerOneScissor("Paper");
            int POS = newGame.GetPlayerOneScore();

            Assert.AreEqual(POS, 1);
        }
        public void GamePlay_ScissorVsScissor_Draw()
        {
            int userInput = 3;
            RockPaperScissor playerOne = new RockPaperScissor(userInput);
            int    computer            = 3;
            string result = "Draw";

            string expectedResult = playerOne.GamePlay(computer);

            Assert.AreEqual(result, expectedResult);
        }
示例#8
0
        public void testPaperScissorExpectScissorsCutPaper()
        {
            Mock <IRockPaperScissorUi> mockUI           = new Mock <IRockPaperScissorUi>();
            RockPaperScissor           rockpaperscissor = new RockPaperScissor(mockUI.Object);
            Player paper   = new Paper(rockpaperscissor);
            Player scissor = new Scissor(rockpaperscissor);

            rockpaperscissor.play(paper, scissor);

            mockUI.Verify(m => m.updateUI("Scissors Cut Paper"));
        }
        public void GamePlay_PaperVsRock_PaperWin()
        {
            int userInput = 2;
            RockPaperScissor playerOne = new RockPaperScissor(userInput);
            int    computer            = 1;
            string result = "Paper Win";

            string expectedResult = playerOne.GamePlay(computer);

            Assert.AreEqual(result, expectedResult);
        }
示例#10
0
        public void testRockScissorExpectRockCrushesScissors()
        {
            Mock <IRockPaperScissorUi> mockUI           = new Mock <IRockPaperScissorUi>();
            RockPaperScissor           rockpaperscissor = new RockPaperScissor(mockUI.Object);
            Player rock    = new Rock(rockpaperscissor);
            Player scissor = new Scissor(rockpaperscissor);

            rockpaperscissor.play(rock, scissor);

            mockUI.Verify(m => m.updateUI("Rock Crushes Scissor"));
        }
示例#11
0
        public void RpsGameWinner_Should_Return_FirstPlayerWin_SameMove()
        {
            var player1 = new PlayerMove("ABC", "P");
            var player2 = new PlayerMove("CBA", "P");

            var retorno = RockPaperScissor.rps_game_winner(
                new List <PlayerMove> {
                player1,
                player2,
            });

            Assert.AreEqual(player1, retorno);
        }
示例#12
0
        public ActionResult GameResult()
        {
            string           POChoice = Request.Form["PlayerOne"];
            string           PTChoice = Request.Form["PlayerTwo"];
            RockPaperScissor newGame  = new RockPaperScissor();

            if (POChoice == "Rock")
            {
                newGame.PlayerOneRock(PTChoice);
            }
            else if (POChoice == "Paper")
            {
                newGame.PlayerOnePaper(PTChoice);
            }
            else if (POChoice == "Scissors")
            {
                newGame.PlayerOneScissor(PTChoice);
            }

            return(View("Index", newGame));
        }
 public void TearDown()
 {
     rps = null;
 }
 public void Setup()
 {
     rps = new RockPaperScissor();
 }
示例#15
0
 public void setup()
 {
     mockUI           = new Mock <IRockPaperScissorUi>();
     rockpaperscissor = new RockPaperScissor(mockUI.Object);
 }
示例#16
0
        public void IsRockPaperScissors_ScissorsOverScissors_True()
        {
            RockPaperScissor newCombination = new RockPaperScissor();

            Assert.AreEqual("draw", newCombination.WinCondition("scissors", "scissors"));
        }
示例#17
0
        public void IsRockPaperScissors_PaperOverPaper_True()
        {
            RockPaperScissor newCombination = new RockPaperScissor();

            Assert.AreEqual("draw", newCombination.WinCondition("paper", "paper"));
        }
示例#18
0
        public void IsRockPaperScissors_RockOverRock_True()
        {
            RockPaperScissor newCombination = new RockPaperScissor();

            Assert.AreEqual("draw", newCombination.WinCondition("rock", "rock"));
        }
示例#19
0
        public void IsRockPaperScissors_PaperOverScissors2_True()
        {
            RockPaperScissor newCombination = new RockPaperScissor();

            Assert.AreEqual("player one wins", newCombination.WinCondition("scissors", "paper"));
        }
示例#20
0
        public void IsRockPaperScissors_RockOverPaper_True()
        {
            RockPaperScissor newCombination = new RockPaperScissor();

            Assert.AreEqual("player two wins", newCombination.WinCondition("rock", "paper"));
        }
示例#21
0
        public ActionResult Index()
        {
            RockPaperScissor newGame = new RockPaperScissor();

            return(View(newGame));
        }
示例#22
0
        static void Main(string[] args)
        {
            bool loop = true;

            do
            {
                Console.Title = $"The Game - Current Wins: {totalWins}";
                Console.WriteLine($"Welcome to the GAME\nSelect an item below\n--------------------------\n" +
                                  $"  - 1. Guess a number\n" +
                                  $"  - 2. Rock Paper Scissors\n" +
                                  $"  - 3. 200 IQ Super Quiz\n" +
                                  $"  - 4. Random Math Questions\n" +
                                  $"  - 5. \n" +
                                  $"  - 6. \n" +
                                  $"  - 7. \n" +
                                  $"  - 8. Roll The Dice\n" +
                                  $"  - 9. Heads or Tails\n" +
                                  $"  - 0. Exit");

                try {
                    int input = Convert.ToInt32(Console.ReadLine());
                    switch (input)
                    {
                    case 1:
                        Console.Clear();
                        GuessNumber.GuessingGame();
                        break;

                    case 2:
                        Console.Clear();
                        RockPaperScissor.RockPaperScissors();
                        break;

                    case 3:
                        Console.Clear();
                        Quiz.The200IQSuperQuiz();
                        break;

                    case 4:
                        Console.Clear();
                        Mg.MathGame();
                        break;

                    case 5:
                        Console.Clear();
                        //none yet
                        break;

                    case 6:
                        Console.Clear();
                        //none yet
                        break;

                    case 7:
                        Console.Clear();
                        //none yet
                        break;

                    case 8:
                        Console.Clear();
                        RTD.RollTheDice();
                        break;

                    case 9:
                        CoinFlips.CoinFlip();
                        Console.Clear();
                        break;

                    case 0:
                        loop = false;
                        break;

                    default:
                        Console.Clear();
                        break;
                    }
                }
                catch (FormatException) {
                    Console.Clear();
                    Console.WriteLine("Input has to be a number.\n");
                }
            } while (loop);
        }
示例#23
0
 public void RpsGameWinner_Should_Raise_WrongNumberOfPlayersError()
 {
     Assert.ThrowsException <WrongNumberOfPlayersError>(() => RockPaperScissor.rps_game_winner(new List <PlayerMove> {
     }));
 }