public void GetPlayerChoice_RockPaoerScissors()
 {
     RockPaperScissors rps = new RockPaperScissors();
       rps.SetPlayer1Choice('q');
       Assert.Equal("Rock", rps.GetPlayer1Choice());
       rps.SetPlayer2Choice('p');
       Assert.Equal("Rock", rps.GetPlayer2Choice());
 }
 public void GetWinner_ForPlayerChoices_PlayerXWin()
 {
     RockPaperScissors rps = new RockPaperScissors();
       rps.SetPlayer2Choice('p');
       rps.SetPlayer1Choice('q');
       Assert.Equal("Tie!", rps.GetWinner());
       rps.SetPlayer2Choice('o');
       Assert.Equal("Player 2 Wins!", rps.GetWinner());
       rps.SetPlayer1Choice('e');
       Assert.Equal("Player 1 Wins!", rps.GetWinner());
 }
 public void GetGameKeysPlayerX_ProvidesKeysToPlayWith()
 {
     RockPaperScissors rps = new RockPaperScissors();
       Dictionary<char, string> keys1 = new Dictionary<char, string>(){};
       keys1.Add('q', "Rock");
       keys1.Add('w', "Paper");
       keys1.Add('e', "Scissors");
       Assert.Equal(keys1, rps.GetGameKeysPlayer1());
       Dictionary<char, string> keys2 = new Dictionary<char, string>() {};
       keys2.Add('p', "Rock");
       keys2.Add('o', "Paper");
       keys2.Add('i', "Scissors");
       Assert.Equal(keys2, rps.GetGameKeysPlayer2());
 }
Esempio n. 4
0
        public HomeModule()
        {
            Get["/"] = _ => {
            RockPaperScissors rps = RockPaperScissors.GetStoredGame();
            if(rps == null)
            {
              rps = new RockPaperScissors();
            }
            return View["play.cshtml", rps];
              };
              Get["/play/{p1}/{p2}"] = parameters => {
            RockPaperScissors rps = RockPaperScissors.GetStoredGame();

            char player1 = parameters.p1;
            char player2 = parameters.p2;

            rps.SetPlayer1Choice(player1);
            rps.SetPlayer2Choice(player2);
            return View["result.cshtml", rps];
              };
              Get["/settings"] = _ => {
            return View["settings.cshtml", RockPaperScissors.GetStoredGame()];
              };
              Post["/settings/save"] = _ => {
            string rock = Request.Form["rock"];
            Console.WriteLine(rock);
            string paper = Request.Form["paper"];
            Console.WriteLine(paper);
            string scissors = Request.Form["scissors"];
            Console.WriteLine(scissors);
            RockPaperScissors rps = RockPaperScissors.GetStoredGame();
            rps.SetRock(rock);
            rps.SetPaper(paper);
            rps.SetScissors(scissors);
            return View["play.cshtml", rps];
              };
        }
 public void Save()
 {
     _rps = this;
 }