public void Can_Build_Hierarchy_String_With_Root_And_Inner_Exception()
        {
            using (var reportInfo = CreateReportInfo())
            {
                reportInfo.ShowExceptionsTab = true;
                reportInfo.SetExceptions(new List <Exception>
                {
                    new ArgumentOutOfRangeException("OuterException",
                                                    new ArgumentNullException("Inner" + "Exception"))
                });

                var expectedExceptionReportString = new StringBuilder().AppendDottedLine()
                                                    .AppendLine("[Exception Info 1]").AppendLine()
                                                    .AppendLine("Top-level Exception")
                                                    .AppendLine("Type:        System.ArgumentOutOfRangeException")
                                                    .AppendLine("Message:     OuterException")
                                                    .AppendLine("Source:      ")
                                                    .AppendLine()
                                                    .AppendLine("Inner Exception 1")
                                                    .AppendLine("Type:        System.ArgumentNullException")
                                                    .AppendLine("Message:     Value cannot be null.")
                                                    .AppendLine("Parameter name: InnerException")
                                                    .AppendLine("Source:")
                                                    .AppendLine().AppendDottedLine().AppendLine();

                var builder         = new ExceptionReportBuilder(reportInfo, new List <SysInfoResult>());
                var exceptionReport = builder.Build();

                Assert.That(exceptionReport.ToString(), Is.EqualTo(expectedExceptionReportString.ToString()));
            }
        }
        /// <summary>
        /// Create an exception report
        /// NB This method re-uses the same information retrieved from the system on subsequent calls
        /// Create a new ExceptionReportGenerator if you need to refresh system information from the computer
        /// </summary>
        /// <returns></returns>
        public ExceptionReport CreateExceptionReport()
        {
            var sysInfoResults = GetOrFetchSysInfoResults();
            var reportBuilder  = new ExceptionReportBuilder(_reportInfo, sysInfoResults);

            return(reportBuilder.Build());
        }
        public void Can_Build_SysInfo_Section()
        {
            var sysInfoResults          = CreateSysInfoResult();
            var expectedExceptionReport = CreateExpectedReport();

            using (var reportInfo = CreateReportInfo())
            {
                reportInfo.ShowSysInfoTab = true;

                var builder         = new ExceptionReportBuilder(reportInfo, sysInfoResults);
                var exceptionReport = builder.Build();

                if (!ExceptionReporter.IsRunningMono())
                {
                    Assert.That(exceptionReport.ToString(), Is.EqualTo(expectedExceptionReport.ToString()));
                }
            }
        }
        public void Can_Build_Referenced_Assemblies_Section()
        {
            using (var reportInfo = CreateReportInfo())
            {
                reportInfo.ShowAssembliesTab = true;
                reportInfo.AppAssembly       = Assembly.GetExecutingAssembly();

                var builder = new ExceptionReportBuilder(reportInfo, new List <SysInfoResult>());

                var exceptionReport = builder.Build();

                Assert.That(exceptionReport, Is.Not.Null);

                var exceptionReportString = exceptionReport.ToString();
                Assert.That(exceptionReportString.Length, Is.GreaterThan(0));
                if (!ExceptionReporter.IsRunningMono())
                {
                    Assert.That(exceptionReportString, Does.Contain("System.Core, Version="));
                }
                Assert.That(exceptionReportString, Does.Contain(Environment.NewLine));
            }
        }