Beispiel #1
0
        public void test_2()
        {
            int a = a1 + a2;

            DFunc.log("The result is changed to " + a);
            DFunc.returnFAIL();
        }
Beispiel #2
0
        public void test_1()
        {
            a1 = 5;
            a2 = 6;
            int a = a1 + a2;

            DFunc.log("The result is " + a);
            DFunc.returnPASS();
        }
Beispiel #3
0
        internal static Test[] getTests(string path)
        {
            ArrayList tests = new ArrayList();

            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader(path))
                {
                    String line;
                    // Read all lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        //skip comments
                        if (line.StartsWith("#"))
                        {
                            continue;
                        }
                        //TestsReader.copyDlls(TestsReader.getLocation(line));
                        tests.Add(TestsReader.generateTest(line));
                    }
                }

                //copy to Test[]
                Test[] results = new Test[tests.Count];
                for (int i = 0; i < tests.Count; i++)
                {
                    results[i] = (Test)tests[i];
                }
                return(results);
            }
            catch (Exception e)
            {
                string msg = "Specified file not found: " + path;
                DFunc.log(msg);
                DFunc.log(e.Message);
                Console.WriteLine(msg);
                return(null);
            }
        }
Beispiel #4
0
        private static void runTest(Type testType, object test, int caseID, string testName)
        {
            string caseName  = "test_" + caseID;
            string undoName  = "test_" + caseID + "_undo";
            string printName = getTestPrintName(testName, caseID);

            try
            {
                MethodInfo testcase = testType.GetMethod(caseName);
                if (testcase == null)
                {
                    throw new Exception("Test method " + caseName + " is not found.");
                }
                testcase.Invoke(test, null);
            }
            catch (Exception e)
            {
                Result r;
                if (e.InnerException != null && e.InnerException is Result)
                {
                    r = (Result)e.InnerException;
                }
                else
                {
                    Console.WriteLine(e.Message);
                    r = new Result(Result.UNRESOLVED);
                }

                Console.WriteLine(putResultToConsole(testName, caseID, r));
                DFunc.printResultInlog(testName, caseID, r);
            }
            finally
            {
                MethodInfo c1u = testType.GetMethod(undoName);
                c1u.Invoke(test, null);
            }
        }
Beispiel #5
0
 public void test_2_undo()
 {
     DFunc.log("Undo");
 }