public void Can_sucessfully_process_the_failing_tests()
        {
            ReportReader reader = new ReportReader(ExtractResourceAttribute.Stream);
            reader.ReadReport();

            // Count the resulting entries
            int failingTests = 0;
            foreach (TestResult test in reader.TestResults)
                failingTests++;

            Assert.AreEqual(4, failingTests);
        }
        private IEnumerable<TestResult> GetTestResults()
        {
            var reportPath = GetMostRecentReport();

            IEnumerable<TestResult> testResults;
            using (var fileStream = new FileStream(reportPath, FileMode.Open))
            {
                var reader = new ReportReader(fileStream);
                reader.ReadReport();
                testResults = reader.TestResults;
            }

            return testResults;
        }
        public ActionResult Upload()
        {
            var u = InternalAttribute.GetUser();

            if (u != null)
            {
                HttpPostedFileBase file         = Request.Files["file"];
                string             guid         = Guid.NewGuid().ToString();
                string             path         = HttpContext.Server.MapPath("/Report1/Temp");
                string             backupPath   = HttpContext.Server.MapPath("/Report1/Backup");
                string             reportFolder = HttpContext.Server.MapPath("/Report1/ReportFiles");

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                if (!Directory.Exists(backupPath))
                {
                    Directory.CreateDirectory(backupPath);
                }

                string fileName = Path.Combine(path, guid + "_" + file.FileName.Split('\\').Last());
                string type     = file.ContentType;
                file.SaveAs(fileName);
                FileInfo fi = new FileInfo(fileName);
                int      atId;
                try
                {
                    if (string.Compare(fi.Extension, ".zip", true) == 0 && int.TryParse(Request.Form["asset"], out atId) && atId > 0)
                    {
                        ZipFile.ExtractToDirectory(fileName, Path.Combine(reportFolder, guid));
                        string reportFile = Path.Combine(reportFolder, guid, "report.xml");
                        if (System.IO.File.Exists(reportFile))
                        {
                            XmlDocument xDoc = new XmlDocument();
                            xDoc.Load(reportFile);
                            Report rp = ReportReader.ReadReport(xDoc);
                            rp.Executor = User.Identity.Name;
                            rp.Uid      = u.Id;
                            using (var db = new SAPTestContext())
                            {
                                rp.Url = guid;
                                // "/Report1/ReportFiles/" + guid + "/report.xml";
                                Asset at = db.Assets.Find(atId);
                                if (at != null)
                                {
                                    rp.Asset = at;
                                }
                                db.Reports.Add(rp);
                                db.SaveChanges();
                            }
                            ViewBag.Flag = true;
                        }
                        else
                        {
                            Directory.Delete(Path.Combine(reportFolder, guid), true);
                            ViewBag.Flag = false;
                        }
                    }
                    else
                    {
                        ViewBag.Flag = false;
                    }
                    System.IO.File.Move(fileName, Path.Combine(backupPath, guid + ".zip"));
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMsg = ex.Message;
                    fi.Delete();
                    if (Directory.Exists(Path.Combine(reportFolder, guid)))
                    {
                        Directory.Delete(Path.Combine(reportFolder, guid), true);
                    }
                    throw new Exception();
                }
                MyReportFilter filter = new MyReportFilter();
                filter.isMyReport = true;
                return(RedirectToAction("Index", filter));
            }
            return(RedirectToAction("Index"));
        }