예제 #1
0
 static async Task Main(string[] args)
 {
     if (args.Length != 1)
     {
         throw new ArgumentException();
     }
     try
     {
         var nunit = new MyNUnit(args[0]);
         nunit.Execute();
         nunit.DisplayResults();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
        public IActionResult ExecuteTests()
        {
            var nunit = new HW5T1.MyNUnit($"{environment.WebRootPath}/Temp");

            nunit.Execute();
            var results        = nunit.GetAllData();
            var assemblyReport = new AssemblyReportModel();
            var idPart         = DateTime.Now;

            foreach (var test in results)
            {
                var currentReport = new TestReportModel();
                currentReport.Name       = test.Name;
                currentReport.Time       = test.TimeOfExecution;
                currentReport.WhyIgnored = test.WhyIgnored;
                currentReport.Id         = idPart.ToString() + '%' + test.Name;
                if (test.Result == "Success")
                {
                    currentReport.Passed = true;
                    assemblyReport.Passed++;
                }
                else if (test.Result == "Failed")
                {
                    currentReport.Passed = false;
                    assemblyReport.Failed++;
                }
                else
                {
                    currentReport.Passed = null;
                    assemblyReport.Ignored++;
                }
                infoContainer.TestReports.Add(currentReport);
                archive.Add(currentReport);
                archive.SaveChanges();
                assemblyReport.TestReports.Add(currentReport);
            }
            this.currentAssembly = assemblyReport;
            currentState.AssemblyReports.Add(assemblyReport);
            return(View("Index", infoContainer.TestReports));
        }