public Report Parse(string reportFilePath, string applicationName) { ValidateReportFilePath(reportFilePath); var reportFile = XDocument.Load(reportFilePath); var testRunId = reportFile.Root.Attribute("id").Value; //identification of version number through the use of a web test within the load test run //we will expect a webtest within the test run list targeting the app version number var namespaces = reportFile.Document.GetNamespaces(); var ns = namespaces[namespaces.Keys.First()]; var reportInputDirectory = Path.GetDirectoryName(reportFilePath); var versionWebTestResultFilePath = reportFile.Root.Element(ns + "Results") .Element(ns + "WebTestResult") .Element(ns + "WebTestResultFilePath").Value; //extract the version number var versionNumber = ExtractVersionInfoFromWebTestResult(reportInputDirectory + "\\" + versionWebTestResultFilePath); var report = new Report() { LoadTestDBId = testRunId, LoadTestRuns = loadTestRunMapper.MapFrom(reportFile.Root).ToList(), DateCreated = DateTime.Now, ApplicationName = applicationName, VersionNumber = versionNumber.Number, VersionUrl = versionNumber.Url }; return report; }
public void Write(Report report) { var server = ServerFactory.Create(); var db = server.GetDatabase("LoadTestReports"); if(!db.CollectionExists("Reports")) db.CreateCollection("Reports"); var reports = db.GetCollection<Report>("Reports"); var reader = new ReportReader(); var existingReport = reader.Get(report.LoadTestDBId); if (existingReport != null) report.Id = existingReport.Id; reports.Save(report); }