Esempio n. 1
0
        private void RunEstimateTest(int testNumber, ArrayList input, string expected)
        {
            AnalaizerClass.opz = input;
            StringBuilder logInfo = new StringBuilder();

            logInfo.Append("\nTest number: ").Append(testNumber).Append("\nВходные данные: ");

            foreach (var v in input)
            {
                logInfo.Append(v).Append(" ");
            }

            string result = AnalaizerClass.RunEstimate();

            logInfo.Append("\nОжидаемый результат: ").Append(expected).Append("\nПолученный результат").Append(result);

            if (result == expected)
            {
                logger.Info(logInfo);
            }
            else
            {
                logger.Error(logInfo);
            }

            Assert.AreEqual(expected, result);
        }
Esempio n. 2
0
        public void RunEstimateTest6()
        {
            ArrayList arrayList = new ArrayList();

            arrayList.Add("2147483645");
            arrayList.Add("m");
            arrayList.Add("2147483646");

            AnalaizerClass.opz = arrayList;
            string actual   = AnalaizerClass.RunEstimate();
            string expected = "Error 03";

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
 static void RunEstimateTest() //Вычисление обратной польской записи
 {
     for (int i = 0; i < 3; i++)
     {
         Console.WriteLine("RunEstimate()");
         ArrayList list = new ArrayList();
         for (int j = 0; j < 3; j++)
         {
             list.Add(Console.ReadLine());
         }
         AnalaizerClass.opz = list;
         string result = AnalaizerClass.RunEstimate();
         Console.WriteLine(result);
     }
 }
Esempio n. 4
0
        private void RunEstimateTest(int testNumber, ArrayList input, string expected)
        {
            AnalaizerClass.opz = input;
            string result = AnalaizerClass.RunEstimate();

            if (result.Contains(expected))
            {
                Log.CreateLog(logger, component, testNumber, ListToString(input), expected, result);
                Assert.AreEqual(true, true);
            }
            else
            {
                Log.CreateBugReport(logger, component, testNumber, ListToString(input), expected, result, "");
                Assert.AreEqual(false, true);
            }
        }
Esempio n. 5
0
        public void RunEstimateTest2()
        {
            ArrayList arrayList = new ArrayList();

            arrayList.Add("34");
            arrayList.Add("p");
            arrayList.Add("3");
            arrayList.Add("-");
            arrayList.Add("0");
            arrayList.Add("/");

            AnalaizerClass.opz = arrayList;
            string actual   = AnalaizerClass.RunEstimate();
            string expected = "Error 09";

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        private static void AnalaizerTest4()
        {
            try
            {
                //1+1
                //1 1 +
                Console.WriteLine("Test 10");
                ArrayList expression = new ArrayList
                {
                    1,
                    1,
                    '+'
                };
                AnalaizerClass.opz = expression;
                Console.WriteLine("Input data: 1 + 1");
                Console.WriteLine("Expected result: 2");
                string result = AnalaizerClass.RunEstimate();
                Console.WriteLine("Result: " + result);
                if (result.Equals("2"))
                {
                    Console.WriteLine("Test complete");
                }
                else
                {
                    Console.WriteLine("Test failed");
                }
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Test failed");
            }

            try
            {
                //1/0
                //1 0 /
                Console.WriteLine("Test 11");
                ArrayList expression = new ArrayList
                {
                    1,
                    0,
                    '/'
                };
                AnalaizerClass.opz = expression;
                Console.WriteLine("Input data: 1 / 0");
                Console.WriteLine("Expected result: Error 09");
                string result = AnalaizerClass.RunEstimate();
                Console.WriteLine("Result: " + result);
                if (result.Equals("Error 09"))
                {
                    Console.WriteLine("Test complete");
                }
                else
                {
                    Console.WriteLine("Test failed");
                }
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Test failed");
            }

            try
            {
                //int.MaxValue * 2 + 1
                //int.MaxValue 2 * 1 +
                Console.WriteLine("Test 12");
                ArrayList expression = new ArrayList
                {
                    (long)int.MaxValue * 2,
                    2,
                    '*',
                    1,
                    '+'
                };
                AnalaizerClass.opz = expression;
                Console.WriteLine("Input data: {0} * 2 + 1", (long)int.MaxValue * 2);
                Console.WriteLine("Expected result: Error 06");
                string result = AnalaizerClass.RunEstimate();
                Console.WriteLine("Result: " + result);
                if (result.Equals("Error 06"))
                {
                    Console.WriteLine("Test complete");
                }
                else
                {
                    Console.WriteLine("Test failed");
                }
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Test failed");
            }

            try
            {
                //-(-(2+2))
                //2 2 + - -
                Console.WriteLine("Test 13");
                ArrayList expression = new ArrayList
                {
                    2,
                    2,
                    '+',
                    '-',
                    '-',
                };
                AnalaizerClass.opz = expression;
                Console.WriteLine("Input data: -(-(2+2))");
                Console.WriteLine("Expected result: Error 03");
                string result = AnalaizerClass.RunEstimate();
                Console.WriteLine("Result: " + result);
                if (result.Equals("Error 03"))
                {
                    Console.WriteLine("Test complete");
                }
                else
                {
                    Console.WriteLine("Test failed");
                }
                Console.WriteLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Test failed");
            }
        }