Example #1
0
        public void IsPingPongGenerator_ReturnPingPong_True()
        {
            int number = 15;
            PingPongGenerator testPingPongGenerator = new PingPongGenerator();

            Assert.AreEqual(true, testPingPongGenerator.IfPingPong(number));
        }
Example #2
0
        public ActionResult Results()
        {
            PingPongGenerator.ClearAll();
            PingPongGenerator pingpong = new PingPongGenerator(int.Parse(Request.Form["inputNumber"]));

            return(View(pingpong.CountsTo()));
        }
Example #3
0
        public ActionResult Result()
        {
            PingPongGenerator newNum = new PingPongGenerator();
            List <string>     result = newNum.GetResult(Int32.Parse(Request.Form["new-game"]));

            return(View(result));
        }
Example #4
0
        public void GetPing_ReturnPingPong_Int()
        {
            int test = 90;
            PingPongGenerator pingPong = new PingPongGenerator();

            Assert.AreEqual(true, pingPong.IfPingPong(test));
        }
Example #5
0
        public ActionResult Display()
        {
            PingPongGenerator newPingPongGenerator = new PingPongGenerator();
            List <string>     model = newPingPongGenerator.PingPong(Int32.Parse(Request.Form["range"]));

            return(View(model));
        }
Example #6
0
        public void PingPongGenerator_ConstructorSetsNumber_True()
        {
            PingPongGenerator newPong = new PingPongGenerator(5);
            int result = newPong.GetPingPongNumber();

            Assert.AreEqual(result, 5);
        }
        public void Test_GetList_FifteenIsPingPong()
        {
            List <string> expectedResult = new List <string> {
                "1", "2", "ping", "4", "pong", "ping", "7", "8", "ping", "pong", "11", "ping", "13", "14", "ping-pong", "16", "17", "ping", "19", "pong", "ping", "22", "23", "ping", "pong", "26", "ping", "28", "29", "ping-pong"
            };

            Assert.Equal(expectedResult, PingPongGenerator.GenerateList(30));
        }
        public void Test_GetList_FiveIsPong()
        {
            List <string> expectedResult = new List <string> {
                "1", "2", "ping", "4", "pong"
            };

            Assert.Equal(expectedResult, PingPongGenerator.GenerateList(5));
        }
        public ActionResult Results(int number)
        {
            PingPongGenerator myPingpongCheck = new PingPongGenerator();

            myPingpongCheck.SetInput(number);
            // myPingpongCheck.PingpongCheck();
            return(View(myPingpongCheck));
        }
Example #10
0
        public void PingPong_ThreeAndFiveToPingPong_Array()
        {
            PingPongGenerator testPingPong = new PingPongGenerator();

            CollectionAssert.AreEqual(new List <string>()
            {
                "1", "2", "ping", "4", "pong", "ping", "7", "8", "ping", "pong", "11", "ping", "13", "14", "ping-pong"
            }, testPingPong.PingPong(15));
        }
Example #11
0
        public void IsPingPong_FollowtheRules_True()
        {
            PingPongGenerator testPingPong = new PingPongGenerator();
            List <string>     testList     = new List <string> {
                "1", "2", "ping"
            };

            CollectionAssert.AreEqual(testList, testPingPong.IsPingPong(3));
        }
Example #12
0
        public void ChangeNumberToString_ChangesToString_True()
        {
            PingPongGenerator newPong = new PingPongGenerator(5);

            Assert.AreEqual("Ping-pong", newPong.ChangeNumberToString(15));
            Assert.AreEqual("Ping", newPong.ChangeNumberToString(3));
            Assert.AreEqual("Pong", newPong.ChangeNumberToString(5));
            Assert.AreEqual("7", newPong.ChangeNumberToString(7));
        }
Example #13
0
        public void PingPong_ReturnsAnArray_Array()
        {
            PingPongGenerator testPingPong = new PingPongGenerator();

            CollectionAssert.AreEqual(new List <string>()
            {
                "1", "2", "3", "4", "5"
            }, testPingPong.PingPong(5));
        }
Example #14
0
        public void PingPong_FiveToPong_Array()
        {
            PingPongGenerator testPingPong = new PingPongGenerator();

            CollectionAssert.AreEqual(new List <string>()
            {
                "1", "2", "ping", "4", "pong"
            }, testPingPong.PingPong(5));
        }
Example #15
0
        public ActionResult Check()
        {
            int inputNumber         = int.Parse(Request.Form["input-number"]);
            PingPongGenerator range = new PingPongGenerator(inputNumber);

            range.ToReplace();
            List <string> AllNumbers = range.GetAll();

            return(View("Result", AllNumbers));
        }
Example #16
0
        public void GetNumberArr_CreatesArray_True()
        {
            PingPongGenerator newPong = new PingPongGenerator(5);
            List <int>        result  = newPong.GetNumberArr();

            CollectionAssert.AreEqual(result, new List <int>()
            {
                1, 2, 3, 4, 5
            });
        }
Example #17
0
 public HomeModule()
 {
     Get["/"] = _ => {
         PingPongGenerator.DeleteAll();
         return(View["index.cshtml"]);
     };
     Post["/ping_pong"] = _ => {
         List <string> ListResult = PingPongGenerator.GenerateList(Request.Form["numInput"]);
         return(View["ping_pong.cshtml", ListResult]);
     };
 }
        public HomeModule()
        {
            Get["/"] = _ => View ["index.cshtml"];
            //loads index view at root//

            Post["/results"] = _ => {
                var newPingPong = new PingPongGenerator(Request.Form["userNumber"]);
                newPingPong.LoadNumber();
                return(View["results.cshtml", newPingPong]);
            };
        }
Example #19
0
        public void DoPingPong_Combine_GetNumberArr_ChangeNumberToString_True()
        {
            List <string> newResult = new List <string>()
            {
                "1", "2", "Ping", "4", "Pong", "Ping"
            };
            PingPongGenerator newPong      = new PingPongGenerator(5);
            List <int>        numArr       = newPong.GetNumberArr();
            List <string>     stringActual = newPong.DoPingPong(numArr);

            Assert.AreEqual(newResult, stringActual);
        }
Example #20
0
        public void GetInput_ReturnInput_Int()
        {
            //Arrange
            int userInput             = 5;
            PingPongGenerator newPong = new PingPongGenerator(userInput);

            //Act
            int result = newPong.GetInput();

            //Assert
            Assert.AreEqual(userInput, result);
        }
Example #21
0
        public void IsPingPongGenerator_ReturnPingPongList_True()
        {
            int userNumber = 15;
            PingPongGenerator testPingPongGenerator = new PingPongGenerator();
            List <string>     testOutput            = testPingPongGenerator.PingPongString(userNumber);
            //testOutput.ForEach(i => Console.WriteLine("{0}\t", i));
            List <string> result = new List <string> {
                "1", "2", "Ping", "4", "Pong", "Ping", "7", "8", "Ping", "Pong", "11", "Ping", "13", "14", "PingPong"
            };

            CollectionAssert.AreEqual(result, testOutput);
        }
        public void AcceptsNumber_SetsNumber_NumberIsSet()
        {
            // Arrange
              int testNumber = 3;

              // Act
              PingPongGenerator myGenerator = new PingPongGenerator(testNumber);
              int result = myGenerator.GetPingPongGeneratorTop();

              // Assert
              // Expected number is first, actual is second
              Assert.Equal(testNumber, result);
        }
Example #23
0
        public void Test1ReturnAllNumbersWithPingsAndPongs()
        {
            //Arrange
              int number = 15;
              PingPongGenerator newGeneration = new PingPongGenerator(number);
              List<string> userList = PingPongGenerator.GetAll();

              //Act
              List<string> testList = new List<string>{"1", "2", "ping", "4", "pong", "ping", "7", "8", "ping", "pong", "11", "ping", "13", "14", "ping-pong" };

              //Assert
              Assert.Equal(testList, userList);
        }
        public void CountsTo_FiveToPong_Object()
        {
            //Arrange
            List <object> fullCount = new List <object> {
                1, 2, "ping", 4, "pong"
            };
            PingPongGenerator pingpong = new PingPongGenerator(5);

            //Act
            List <object> result = pingpong.GetList();

            //Assert
            CollectionAssert.AreEqual(fullCount, result);
        }
        public void CountsTo_CountToNumber_Object()
        {
            //Arrange
            List <object> fullCount = new List <object> {
                1, 2
            };
            PingPongGenerator pingpong = new PingPongGenerator(2);

            //Act
            List <object> result = pingpong.GetList();

            //Assert
            CollectionAssert.AreEqual(fullCount, result);
        }
        public void CountsTo_FiveToPong_ListOfObject()
        {
            //Arrange
            List <object> expected = new List <object> {
                1, 2, "ping", 4, "pong"
            };

            //Act
            PingPongGenerator pingpong = new PingPongGenerator(5);
            List <object>     actual   = pingpong.CountsTo();

            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
Example #27
0
        public void GetPingPongOutput_ReturnPingPongList_String()
        {
            int userInputNumber        = 15;
            PingPongGenerator pingPong = new PingPongGenerator();
            List <string>     testList = pingPong.PingPongOutput(userInputNumber);

            testList.ForEach(i => Console.Write("{0}\t", i));
            Console.WriteLine("");
            List <string> expectedResult = new List <string> {
                "1", "2", "Ping", "4", "Pong", "Ping", "7", "8", "Ping", "Pong", "11", "Ping", "13", "14", "Ping-Pong"
            };

            CollectionAssert.AreEqual(expectedResult, testList);
        }
Example #28
0
    public static void Main()
    {
        Console.WriteLine("Please enter a number");
        int input = int.Parse(Console.ReadLine());

        Console.WriteLine("Here are the results! Ping-Pong!");

        IEnumerable <int> inputRange = Enumerable.Range(1, input);

        foreach (int n in inputRange)
        {
            PingPongGenerator checkPingPong = new PingPongGenerator();
            Console.WriteLine(checkPingPong.IsPingPong(n));
        }
    }
Example #29
0
        public void CountInput_ReturnCountedInput_List()
        {
            //Arrange
            List <int> greatList = new List <int> {
                1, 2, 3, 4, 5
            };
            int userInput             = 5;
            PingPongGenerator newPong = new PingPongGenerator(userInput);

            //Act
            List <int> result = newPong.CountInput(newPong.GetInput());

            //Assert
            CollectionAssert.AreEqual(greatList, result);
        }
        public void CountsTo_CountsToNumber_ListOfObject()
        {
            //Arrange
            List <object> expected = new List <object> {
                1, 2
            };

            //Act
            PingPongGenerator pingpong = new PingPongGenerator(2);
            List <object>     actual   = pingpong.CountsTo();

            //Assert
            CollectionAssert.AreEqual(expected, actual);
            // CollectionAssert.AreEqual(expected, actual);
        }
Example #31
0
        //_Replace all numbers divisible by 3 with Ping_
        //output is a list of strings, so method will have to convert int to string
        public void ReplacePingPong_ReturnPing_List()
        {
            //Arrange
            int userInput = 5;
            PingPongGenerator newPingPong  = new PingPongGenerator(userInput);
            List <string>     pingPongList = new List <string> {
                "1", "2", "ping", "4", "pong"
            };
            List <int> origList = newPingPong.CountInput(newPingPong.GetInput());

            //Act
            List <string> result = newPingPong.ReplacePingPong(origList);

            //Assert
            CollectionAssert.AreEqual(pingPongList, result);
        }
        public void GenerateNumberArray_GeneratesNumberArray_NumberArrayCreated()
        {
            // Arrange
              int topNumber = 5;
              int[] testArray = new int[5];
              testArray[0] = 1;
              testArray[1] = 2;
              testArray[2] = 3;
              testArray[3] = 4;
              testArray[4] = 5;

              // Act
              PingPongGenerator newGenerator = new PingPongGenerator(topNumber);
              int[] newArray = newGenerator.CreateNumberArray(topNumber);

              // Assert
              Assert.Equal(testArray, newArray);
        }
        public void CountsTo_FifteenToPingPong_ListOfObject()
        {
            //Arrange
            List <object> expected = new List <object> {
                1, 2, "ping", 4, "pong", "ping", 7, 8, "ping", "pong", 11, "ping", 13, 14, "ping-pong"
            };

            //Act
            PingPongGenerator pingpong = new PingPongGenerator(15);
            List <object>     actual   = pingpong.CountsTo();

            // for (int i = 0; i < result.Count; i++)
            // {
            //   Console.WriteLine("Output: " + result[i]);
            // }
            //Assert
            CollectionAssert.AreEqual(expected, actual);
        }
        public void ReplaceFives_ReplacesFivesWithPong_FiveIsPong()
        {
            // Arrange
              int nextNumber = 5;
              ArrayList testFivesList = new ArrayList();
              testFivesList.Add(1);
              testFivesList.Add(2);
              testFivesList.Add(3);
              testFivesList.Add(4);
              testFivesList.Add("pong");
              int[] testArray = new int[5];
              testArray[0] = 1;
              testArray[1] = 2;
              testArray[2] = 3;
              testArray[3] = 4;
              testArray[4] = 5;

              // Act
              PingPongGenerator newGenerator = new PingPongGenerator(nextNumber);
              ArrayList resultFivesList = newGenerator.ReplaceFives(testArray);

              // Assert
              Assert.Equal(testFivesList, resultFivesList);
        }
        public void ReplaceThreeFives_ReplacesThreeFivesWithPingPong_ThreeFiveIsPong()
        {
            // Arrange
              int nextNumber = 15;
              ArrayList testThreeFivesList = new ArrayList();
              testThreeFivesList.Add(1);
              testThreeFivesList.Add(2);
              testThreeFivesList.Add("ping");
              testThreeFivesList.Add(4);
              testThreeFivesList.Add("pong");
              testThreeFivesList.Add("ping");
              testThreeFivesList.Add(7);
              testThreeFivesList.Add(8);
              testThreeFivesList.Add("ping");
              testThreeFivesList.Add("pong");
              testThreeFivesList.Add(11);
              testThreeFivesList.Add("ping");
              testThreeFivesList.Add(13);
              testThreeFivesList.Add(14);
              testThreeFivesList.Add("ping-pong");
              int[] testArray = new int[15];
              testArray[0] = 1;
              testArray[1] = 2;
              testArray[2] = 3;
              testArray[3] = 4;
              testArray[4] = 5;
              testArray[5] = 6;
              testArray[6] = 7;
              testArray[7] = 8;
              testArray[8] = 9;
              testArray[9] = 10;
              testArray[10] = 11;
              testArray[11] = 12;
              testArray[12] = 13;
              testArray[13] = 14;
              testArray[14] = 15;

              // Act
              PingPongGenerator newGenerator = new PingPongGenerator(nextNumber);
              ArrayList resultThreeFivesList = newGenerator.ReplaceThreeFives(testArray);

              // Assert
              for (int i = 0; i < 15; i++) { Console.WriteLine(resultThreeFivesList[i]); }
              Assert.Equal(testThreeFivesList, resultThreeFivesList);
        }
        public void ReplaceThrees_ReplacesThreesWithPing_ThreeIsPing()
        {
            // Arrange
              int nextNumber = 3;
              ArrayList testThreesList = new ArrayList();
              testThreesList.Add(1);
              testThreesList.Add(2);
              testThreesList.Add("ping");
              int[] testArray = new int[3];
              testArray[0] = 1;
              testArray[1] = 2;
              testArray[2] = 3;

              // Act
              PingPongGenerator newGenerator = new PingPongGenerator(nextNumber);
              ArrayList resultThreesList = newGenerator.ReplaceThrees(testArray);

              // Assert
              Assert.Equal(testThreesList, resultThreesList);
        }