コード例 #1
0
ファイル: HomeModules.cs プロジェクト: Rick1970/Rock-Paper
        public Game()
        {
            Get["/"] = _ =>{
            return View["index.cshtml"];
              };

              Get["/play1"] = _ =>{
            return View["play1.cshtml"];
              };

              Post["/player_1_input"] = _ => {
            Player player1 = new Player(Request.Form["input1"]);
            player1.Save();
            return View["play2.cshtml"];
              };
              Post["/player_2_input"] = _ =>{
            Player player2 = new Player(Request.Form["input2"]);
            player2.Save();
            return View["ready.cshtml"];
              };
              Get["/who_wins"] = _ =>{
            List<Player>allPlays = new Player.GetAll();
            return View["/result.cshtml", allPlays];
              };
        }
コード例 #2
0
ファイル: PlayerTest.cs プロジェクト: Rouz1130/Rock-Paper
        public void Test_PlayerGetPlay_true()
        {
            //Arrange
              Player player1 = new Player("Rock");

              //Act
              string currentPlay = player1.GetPlay();

              //Assert
              Assert.Equal("Rock", currentPlay);
        }
コード例 #3
0
ファイル: HomeModules.cs プロジェクト: Rouz1130/Rock-Paper
        public Game()
        {
            Get["/"] = _ =>{
            return View["index.cshtml"];
              };

              Get["/player1"] = _ =>{
            return View["player1.cshtml"];
              };

              Post["/player_1_input"] = _ => {
            Player player1 = new Player(Request.Form["input1"]);
            player1.Save();
            return View["player2.cshtml"];
              };
        }
コード例 #4
0
ファイル: PlayerTest.cs プロジェクト: Rouz1130/Rock-Paper
        public void Test_PlayAGame_SciBeatPap_true()
        {
            //Arrange
              Player player1 = new Player("Scissors");
              player1.Save();
              Player player2 = new Player("Paper");
              player2.Save();

              //Act
              //write a method to determine the winner
              string result = Player.Shoot(player1, player2);
              //Assert
              Console.WriteLine(player1);
              Console.WriteLine(player2);

              Assert.Equal("PLAYER 1 WINS", result);
        }
コード例 #5
0
ファイル: PlayerTest.cs プロジェクト: Rouz1130/Rock-Paper
        public void Test_PlayAGame_DRAW_true()
        {
            //Arrange
              Player player1 = new Player("Rock");
              player1.Save();
              Player player2 = new Player("Rock");
              player2.Save();

              //Act
              //write a method to determine the winner
              string result = Player.Shoot(player1, player2);
              //Assert
              Console.WriteLine(player1);
              Console.WriteLine(player2);

              Assert.Equal("DRAW", result);
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: Rouz1130/Rock-Paper
        public static string Shoot(Player player1, Player player2)
        {
            string output1 = "DRAW";
              string output2 = "PLAYER 1 WINS";
              // string output3 = "Player 2 wins!!";

              if (player1.GetPlay() == player2.GetPlay())
              {
              return output1;
              }
              else if (((player1.GetPlay() == "Scissors") && (player2.GetPlay() == "Paper")) || ((player1.GetPlay() == "Rock") && (player2.GetPlay() == "Scissors")))
              {
            return output2;
              }
              else
              {
            return null;
              }
        }
コード例 #7
0
ファイル: PlayerTest.cs プロジェクト: Rouz1130/Rock-Paper
        public void Test_PlayerSave_true()
        {
            //Arrange
              Player player1 = new Player("Rock");
              player1.Save();

              //Act
              List<Player> allPlayers = Player.GetAll();

              //Assert
              Assert.Equal(player1, allPlayers[0]);
        }
コード例 #8
0
ファイル: PlayerTest.cs プロジェクト: Rouz1130/Rock-Paper
        public void Test_TwoPlayersSave_true()
        {
            //Arrange
              Player player1 = new Player("Rock");
              player1.Save();
              Player player2 = new Player("Paper");
              player2.Save();

              //Act
              List<Player> allPlayers = Player.GetAll();

              //Assert
              // Console.WriteLine(new List<Player>() {player1, player2});
              Console.WriteLine(allPlayers.Count);
              Assert.Equal(player1, allPlayers[0]);
              Assert.Equal(player2, allPlayers[1]);
        }