示例#1
0
        static void SystemTest(ItemPacking ip)
        {
            Console.WriteLine("Start Testing...");
            int       totalNum  = 0;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            foreach (string productCode in ip.productList.Keys)
            {
                //Special Cases
                ip.ResponseToInput(-1, productCode, true);
                ip.ResponseToInput(0, productCode, true);
                ip.ResponseToInput(1, productCode, true);
                totalNum += 3;
                for (int i = 2; i <= 80; i++)
                {
                    //Only display successful cases
                    ip.ResponseToInput(i, productCode, false);
                    totalNum++;
                }
            }
            stopwatch.Stop();
            TimeSpan timespan = stopwatch.Elapsed;
            double   seconds  = timespan.TotalSeconds;

            Console.WriteLine("Tested {0} cases, using {1} seconds.", totalNum, seconds);
            Console.WriteLine("");
        }
示例#2
0
 static void UserInteraction(ItemPacking ip)
 {
     while (true)
     {
         Console.WriteLine("Now you can input to test any other cases...");
         Console.WriteLine("Please input the number you want for the product and the product code:");
         string[] input = Console.ReadLine().Split(' ');
         if (input.Length != 2)
         {
             Console.WriteLine("Your input format should be \'<Product Number> <Product Code>\'. E.g. \'10 SH3\'.");
             continue;
         }
         bool isInputDigit = int.TryParse(input[0], out int number);
         if (!isInputDigit)
         {
             Console.WriteLine("Your input format should be \'<Product Number> <Product Code>\'. E.g. \'10 SH3\'.");
             continue;
         }
         ip.ResponseToInput(number, input[1], true);
     }
 }