Exemple #1
0
        //12/03/18, By Jonathan
        //This function extracts Pex results for a single project in the editedMetaProject folder
        public static Tuple <HashSet <string[]>, HashSet <string[]>, string> ExtractTestsForEditedMetaProject(string editedMetaProject, string fileName, string className, string methodName, string assemblyName)
        {
            string      assemblyFile = FileModifier.GetAssemblyFileOfProject(editedMetaProject, assemblyName);
            MethodInfo  method       = RunTest.GetMethodDefinition(assemblyFile, className, methodName);
            List <Test> tests        = ExtractTestsForProject(editedMetaProject, method);

            if (tests != null)
            {
                //Try to create "PexTests" directory. Nothing happens if already exists
                System.IO.Directory.CreateDirectory(editedMetaProject + @"\PexTests");
                string xmlFileName = editedMetaProject + @"\PexTests\" + fileName + "_PexTests.xml";
                Serializer.SerializeTests(tests, xmlFileName);
            }

            //Notify caller of infin runtime / null ref exception
            return(Tuple.Create(g_PassedTests, g_FailedTests, g_failType));
        }
Exemple #2
0
 public static void GenerateRandomTests(string topDir, int numOfTests)
 {
     foreach (string taskDir in Directory.GetDirectories(topDir))
     {
         MethodInfo method = null;
         foreach (var studentDir in Directory.GetDirectories(taskDir))
         {
             if (studentDir.EndsWith("secret_project"))
             {
                 string assemblyFile = FileModifier.GetAssemblyFileOfProject(studentDir);
                 method = RunTest.GetMethodDefinition(assemblyFile, "Program", "Puzzle");
                 List <Test> tests    = GenerateTestsForProject(method, numOfTests);
                 string      fileName = studentDir + @"\RandomTests.xml";
                 Serializer.SerializeTests(tests, fileName);
                 break;
             }
         }
     }
 }
 public static void ExtractPexTests(string topDir)
 {
     foreach (string taskDir in Directory.GetDirectories(topDir))
     {
         MethodInfo method = null;
         foreach (var studentDir in Directory.GetDirectories(taskDir))
         {
             if (studentDir.EndsWith("secret_project"))
             {
                 string assemblyFile = FileModifier.GetAssemblyFileOfProject(studentDir);
                 method = RunTest.GetMethodDefinition(assemblyFile, "Program", "Puzzle");
                 List <Test> tests = ExtractTestsForProject(studentDir, method);
                 if (tests != null)
                 {
                     string fileName = studentDir + @"\PexTests.xml";
                     Serializer.SerializeTests(tests, fileName);
                 }
                 break;
             }
         }
         foreach (var studentDir in Directory.GetDirectories(taskDir))
         {
             if (studentDir.EndsWith("secret_project"))
             {
                 continue;
             }
             foreach (var projectDir in Directory.GetDirectories(studentDir))
             {
                 List <Test> tests = ExtractTestsForProject(projectDir, method);
                 if (tests != null)
                 {
                     string fileName = projectDir + @"\PexTests.xml";
                     Serializer.SerializeTests(tests, fileName);
                 }
             }
         }
     }
 }