public void Constructs_with_null_resourcePaths_should_throw_exception() { var mockPreferenceManager = MockRepository.GenerateStub <IPreferenceManager>(); var fakeReportPreferenceManager = new ReportPreferenceManager(mockPreferenceManager); new VtlReportFormatter(fakeReportPreferenceManager, "ext", MimeTypes.PlainText, new DirectoryInfo("content"), "vm", null, true); }
public void Constructs_with_null_templatePath_should_throw_exception() { var mockPreferenceManager = MockRepository.GenerateStub <IPreferenceManager>(); var fakeReportPreferenceManager = new ReportPreferenceManager(mockPreferenceManager); new VtlReportFormatter(fakeReportPreferenceManager, "ext", MimeTypes.PlainText, new DirectoryInfo("content"), null, EmptyArray <string> .Instance, true); }
public void Format() { var mockPreferenceStore = MockRepository.GenerateStub <IPreferenceStore>(); var mockPreferenceManager = MockRepository.GenerateStub <IPreferenceManager>(); var mockPreferenceSet = MockRepository.GenerateStub <IPreferenceSet>(); mockPreferenceManager.Stub(x => x.LocalUserPreferences).Return(mockPreferenceStore); mockPreferenceStore.Stub(x => x["Gallio.Reports"]).Return(mockPreferenceSet); mockPreferenceSet.Stub(x => x.Read <bool>(null)).IgnoreArguments().Return(false); mockPreferenceSet.Stub(x => x.Read <int>(null)).IgnoreArguments().Return(2000); var fakeReportPreferenceManager = new ReportPreferenceManager(mockPreferenceManager); var mockReportWriter = MockRepository.GenerateStub <IReportWriter>(); var mockReportContainer = MockRepository.GenerateStub <IReportContainer>(); var mockProgressMonitor = NullProgressMonitor.CreateInstance(); var output = new StringBuilder(); var stream = new StringStream(output); var fakeReport = new Report(); mockReportWriter.Stub(x => x.Report).Return(fakeReport); mockReportWriter.Stub(x => x.ReportContainer).Return(mockReportContainer); mockReportContainer.Stub(x => x.ReportName).Return("output"); mockReportContainer.Stub(x => x.OpenWrite(null, null, null)).IgnoreArguments().Return(stream); fakeReport.TestPackageRun = new TestPackageRun(); fakeReport.TestPackageRun.RootTestStepRun = new TestStepRun(new TestStepData("", "", "", "")); fakeReport.TestPackageRun.Statistics.RunCount = 123; var formatter = new VtlReportFormatter(fakeReportPreferenceManager, "ext", MimeTypes.PlainText, new DirectoryInfo("content"), "Gallio.Tests.Reports.SampleTemplate.vm", EmptyArray <string> .Instance, false); formatter.VelocityEngineFactory = new ResourceVelocityEngineFactory(); formatter.Format(mockReportWriter, new ReportFormatterOptions(), mockProgressMonitor); Assert.AreEqual("This is the test report (123)", output.ToString()); }
/// <summary> /// Creates a VTL report formatter. /// </summary> /// <param name="preferenceManager">The user preference manager</param> /// <param name="extension">The preferred extension without a '.'</param> /// <param name="contentType">The content type of the main report document.</param> /// <param name="resourceDirectory">The resource directory.</param> /// <param name="templatePath">The path of the NVelocity template relative to the resource directory.</param> /// <param name="resourcePaths">The paths of the resources (such as images or CSS) to copy to the report directory relative to the resource directory.</param> /// <param name="supportSplit">Indicates whether the format supports file splitting.</param> /// <exception cref="ArgumentNullException">Thrown if any arguments are null.</exception> public VtlReportFormatter(ReportPreferenceManager preferenceManager, string extension, string contentType, DirectoryInfo resourceDirectory, string templatePath, string[] resourcePaths, bool supportSplit) { if (preferenceManager == null) { throw new ArgumentNullException(@"preferenceManager"); } if (extension == null) { throw new ArgumentNullException(@"extension"); } if (contentType == null) { throw new ArgumentNullException(@"contentType"); } if (resourceDirectory == null) { throw new ArgumentNullException(@"resourceDirectory"); } if (templatePath == null) { throw new ArgumentNullException(@"templatePath"); } if (resourcePaths == null || Array.IndexOf(resourcePaths, null) >= 0) { throw new ArgumentNullException(@"resourcePaths"); } this.preferenceManager = preferenceManager; this.extension = extension; this.contentType = contentType; this.resourceDirectory = resourceDirectory; this.templatePath = templatePath; this.resourcePaths = resourcePaths; this.supportSplit = supportSplit; templateFilePath = Path.Combine(resourceDirectory.FullName, templatePath); }
/// <summary> /// /// </summary> /// <param name="preferenceManager"></param> public ReportPreferencePaneProvider(ReportPreferenceManager preferenceManager) { this.preferenceManager = preferenceManager; }