Пример #1
0
 public HomeModule()
 {
     Get["/"]         = _ => View["input_form.cshtml"];
     Post["/results"] = _ => {
         int maxNumber = int.Parse(Request.Form["number"]);
         PingPongGenerator pingpong = new PingPongGenerator();
         List <string>     results  = pingpong.IsPingPong(maxNumber);
         return(View["results.cshtml", results]);
     };
 }
 public void PingPongGenerator_ForNumberDivisibleByThree_true()
 {
     PingPongGenerator pingpong = new PingPongGenerator();
       List<string> result = pingpong.IsPingPong(3);
       foreach (string index in result)
       {
     Console.WriteLine(index);
       }
       Assert.Equal(result, pingpong.IsPingPong(3));
 }
 public HomeModule()
 {
     Get["/"] = _ => View["input_form.cshtml"];
       Post["/results"] = _ => {
     int maxNumber = int.Parse(Request.Form["number"]);
     PingPongGenerator pingpong = new PingPongGenerator();
     List<string> results = pingpong.IsPingPong(maxNumber);
     return View["results.cshtml", results];
       };
 }
Пример #4
0
        public void Generate_PingPongOutput_true()
        {
            //Arrange
            int    userInput  = 15;
            string testOutput = "PingPong";
            //Act
            List <string> output = PingPongGenerator.Generate(userInput);

            //Assert
            Assert.Equal(true, testOutput == output[14]);
        }
Пример #5
0
        public void PingPongGenerator_ForNumberDivisibleByThree_true()
        {
            PingPongGenerator pingpong = new PingPongGenerator();
            List <string>     result   = pingpong.IsPingPong(3);

            foreach (string index in result)
            {
                Console.WriteLine(index);
            }
            Assert.Equal(result, pingpong.IsPingPong(3));
        }
Пример #6
0
 public HomeModule()
 {
     Get["/"] = _ => View ["pingpong.cshtml"];
     Post["show_pingpong"] = _ => {       //when user submit the form after entering the number
         //Read the user input
         int userNumber = int.Parse(Request.Form["input-number"]);
         PingPongGenerator newPingPong = new PingPongGenerator();
         List <string>     listResult  = newPingPong.Generate_PingPong(userNumber);
         return(View ["view_pingpong.cshtml", listResult]);
     };
 }
Пример #7
0
 public HomeModule()
 {
     Get["/"] = _ => {
         List <string> model = new List <string> {
         };
         return(View["pingpong.cshtml", model]);
     };
     Post["/"] = _ => {
         List <string> newList = PingPongGenerator.Generate(int.Parse(Request.Form["input-num"]));
         return(View["pingpong.cshtml", newList]);
     };
 }
Пример #8
0
        public ActionResult Convert()
        {
            int userNum = int.Parse(Request.Form["number"]);
            PingPongGenerator newPingPong = new PingPongGenerator(userNum);

            List <int>    userList    = newPingPong.CountInput(newPingPong.GetInput());
            List <string> replaceList = newPingPong.ReplacePingPong(userList);

            // string output = string.Join(",", replaceList.ToArray());
            // Console.WriteLine(output);

            return(View("Index", replaceList));
        }
Пример #9
0
        public void Generate_CountsUpToUserInput_ReturnsListOfInts()
        {
            //Arrange
            int           userInput  = 3;
            List <string> testOutput = new List <string> {
                "1", "2", "Ping"
            };
            //Act
            List <string> output = PingPongGenerator.Generate(userInput);

            //Assert
            Assert.Equal(testOutput, output);
        }
Пример #10
0
        public static void Main()
        {
            PingPongGenerator game = new PingPongGenerator();

            game.Run();
        }