Esempio n. 1
0
        public void outOfScope()
        {
            int noBags  = 0;
            int negBags = -5;

            PotatoProblems.PotatoeLogic spudnik = new PotatoProblems.PotatoeLogic();
            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => spudnik.differenceAboveForty(noBags));
            Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => spudnik.differenceAboveForty(negBags));
        }
Esempio n. 2
0
        /****************************************************************************
        * Function Name: Main
        * Author: Samuel Bakes
        * Parameters: OS arguments not used in Program.
        * Description: This function prompts the user for the number of bags, and outputs the
        *              difference in potatoes. All error handling occurs in this function.
        ****************************************************************************/
        static void Main(string[] args)
        {
            InputOutput  ui                = new InputOutput();
            PotatoeLogic spudnik           = new PotatoeLogic(); // In memory of the first Earth satelite.
            int          numBags           = ui.getInput();
            int          potatoeDifference = spudnik.differenceAboveForty(numBags);

            ui.setOutput(potatoeDifference);
        }
Esempio n. 3
0
 public void validAboveFortySpeedTest()
 {
     PotatoProblems.PotatoeLogic x = new PotatoProblems.PotatoeLogic();
     int[] expectedResult          = { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820 };
     for (int k = 0; k < 5; k++)  // The following loops are used to call the test function enough times to find a distinction between functions.
     {
         for (int j = 0; j < 5; j++)
         {
             for (int i = 1; i <= 40; i++)
             {
                 int actualResult = x.differenceAboveForty(i);
                 Assert.AreEqual(expectedResult[i - 1], actualResult, 0, "Valid Input Failed.");
             }
         }
     }
 }