Example #1
0
        private static bool ParseImpl(string value, out ReportArchive reportArchive, bool throwOnFailure)
        {
            if (String.IsNullOrEmpty(value))
            {
                reportArchive = Normal;
                return(true);
            }

            foreach (ReportArchive item in All)
            {
                if (item.Value.ToString().Equals(value, StringComparison.OrdinalIgnoreCase))
                {
                    reportArchive = item;
                    return(true);
                }
            }

            if (throwOnFailure)
            {
                string[] names = GenericCollectionUtils.ToArray(GenericCollectionUtils.Select(All, x => x.Value.ToString()));
                throw new ArgumentException(String.Format("Invalid report archive mode '{0}'. It must be one of the following values: {1}.",
                                                          value, String.Join(", ", names)));
            }

            reportArchive = Normal;
            return(false);
        }
 internal void TryParse(string value, bool expectedResult, ReportArchive.ReportArchiveValue expectedMode)
 {
     ReportArchive actualMode;
     bool actualResult = ReportArchive.TryParse(value, out actualMode);
     Assert.AreEqual(expectedResult, actualResult);
     Assert.AreEqual(expectedMode, actualMode.Value);
 }
        /// <summary>
        /// Makes a report container for a saving operation.
        /// </summary>
        /// <param name="reportArchive">Indicates if the report must be packed in a compressed archive.</param>
        /// <returns>A new instance of report container.</returns>
        /// <exception cref="ArgumentNullException">Thrown if any argument is null.</exception>
        public IReportContainer MakeForSaving(ReportArchive reportArchive)
        {
            if (reportArchive == null)
            {
                throw new ArgumentNullException("reportArchive");
            }

            return((IReportContainer)Activator.CreateInstance(reportArchive.ReportContainerForSavingType, reportDirectory, reportName));
        }
        /// <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));
            }
        }
 internal void Parse(string value, ReportArchive.ReportArchiveValue expectedMode)
 {
     ReportArchive actualMode = ReportArchive.Parse(value);
     Assert.AreEqual(expectedMode, actualMode.Value);
 }
Example #6
0
        private static bool ParseImpl(string value, out ReportArchive reportArchive, bool throwOnFailure)
        {
            if (String.IsNullOrEmpty(value))
            {
                reportArchive = Normal;
                return true;
            }

            foreach (ReportArchive item in All)
            {
                if (item.Value.ToString().Equals(value, StringComparison.OrdinalIgnoreCase))
                {
                    reportArchive = item;
                    return true;
                }
            }

            if (throwOnFailure)
            {
                string[] names = GenericCollectionUtils.ToArray(GenericCollectionUtils.Select(All, x => x.Value.ToString()));
                throw new ArgumentException(String.Format("Invalid report archive mode '{0}'. It must be one of the following values: {1}.",
                    value, String.Join(", ", names)));
            }

            reportArchive = Normal;
            return false;
        }
Example #7
0
 /// <summary>
 /// Parses the specified value and returns the corresponding <see cref="ReportArchive"/> value,
 /// or the default value if null or an empty string was specified.
 /// </summary>
 /// <param name="value">The value of the searched archive.</param>
 /// <param name="reportArchive">The resulting report archive item.</param>
 /// <returns>True if the parsing was successful; otherwise false.</returns>
 public static bool TryParse(string value, out ReportArchive reportArchive)
 {
     return ParseImpl(value, out reportArchive, false);
 }
Example #8
0
 /// <summary>
 /// Parses the specified value and returns the corresponding <see cref="ReportArchive"/> value,
 /// or the default value if null or an empty string was specified.
 /// </summary>
 /// <param name="value">The value of the searched archive.</param>
 /// <param name="reportArchive">The resulting report archive item.</param>
 /// <returns>True if the parsing was successful; otherwise false.</returns>
 public static bool TryParse(string value, out ReportArchive reportArchive)
 {
     return(ParseImpl(value, out reportArchive, false));
 }
        /// <summary>
        /// Makes a report container for a saving operation.
        /// </summary>
        /// <param name="reportArchive">Indicates if the report must be packed in a compressed archive.</param>
        /// <returns>A new instance of report container.</returns>
        /// <exception cref="ArgumentNullException">Thrown if any argument is null.</exception>
        public IReportContainer MakeForSaving(ReportArchive reportArchive)
        {
            if (reportArchive == null)
                throw new ArgumentNullException("reportArchive");

            return (IReportContainer)Activator.CreateInstance(reportArchive.ReportContainerForSavingType, reportDirectory, reportName);
        }