public void MakeForReading_from_flat_file() { var mockFileSystem = MockRepository.GenerateMock<IFileSystem>(); mockFileSystem.Expect(x => x.FileExists(@"C:\directory\name.zip")).Return(false); var factory = new ReportContainerFactory(mockFileSystem, @"C:\directory", "name"); var container = factory.MakeForReading(); Assert.IsInstanceOfType<FileSystemReportContainer>(container); mockFileSystem.VerifyAllExpectations(); }
public void MakeForSaving_with_archive() { var mockFileSystem = MockRepository.GenerateStub<IFileSystem>(); var factory = new ReportContainerFactory(mockFileSystem, @"C:\Directory", "name"); var container = (AbstractReportContainer)factory.MakeForSaving(ReportArchive.Zip); Assert.IsInstanceOfType<ArchiveReportContainer>(container); Assert.AreEqual("name", container.ReportName); Assert.AreEqual(@"C:\Directory\", container.ReportDirectory); }
/// <summary> /// Generates reports of the desired forms. /// </summary> /// <remarks> /// <para> /// This method adds the paths of the generated report documents to <see cref="ReportDocumentPaths" />. /// </para> /// </remarks> /// <param name="reportDirectory">The report directory.</param> /// <param name="reportName">The report name.</param> /// <param name="reportArchive">Determines whether to enclose the resulting test report in a compressed archive file.</param> /// <param name="reportFormats">The report formats to generate.</param> /// <param name="reportFormatOptions">The report formatter options.</param> /// <param name="reportManager">The report manager.</param> /// <param name="progressMonitor">A progress monitor for the operation.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="reportDirectory"/>, /// <paramref name="reportName"/>, <paramref name="reportFormats"/>, <paramref name="reportFormatOptions"/>, /// <paramref name="reportManager"/>, or <paramref name="progressMonitor"/> is null.</exception> public void GenerateReports(string reportDirectory, string reportName, ReportArchive reportArchive, IList<string> reportFormats, ReportFormatterOptions reportFormatOptions, IReportManager reportManager, IProgressMonitor progressMonitor) { if (reportDirectory == null) throw new ArgumentNullException("reportDirectory"); if (reportName == null) throw new ArgumentNullException("reportName"); if (reportFormats == null) throw new ArgumentNullException("reportFormats"); if (reportFormatOptions == null) throw new ArgumentNullException("reportFormatOptions"); if (reportManager == null) throw new ArgumentNullException("reportManager"); if (progressMonitor == null) throw new ArgumentNullException("progressMonitor"); var factory = new ReportContainerFactory(new FileSystem(), reportDirectory, reportName); using (progressMonitor.BeginTask("Generating reports.", reportFormats.Count)) using (IReportContainer reportContainer = factory.MakeForSaving(reportArchive)) { IReportWriter reportWriter = reportManager.CreateReportWriter(report, reportContainer); // Delete the report if it exists already. reportContainer.DeleteReport(); // Format the report in all of the desired ways. foreach (string reportFormat in reportFormats) { using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1)) reportManager.Format(reportWriter, reportFormat, reportFormatOptions, subProgressMonitor); } // Save the full paths of the documents. foreach (string reportDocumentPath in reportWriter.ReportDocumentPaths) AddReportDocumentPath(Path.Combine(reportDirectory, reportDocumentPath)); } }