public async Task WithAllMembersIncludedOnStackTrace_should_make_format_printing_all_members_of_stack_trace() { var exception = await MakeSampleException(); var expectedExceptionDetails = @"^System.Exception : ThrowSampleExceptionAsync ---> System.InvalidOperationException : ThrowInnerExceptionAsync ---> System.AggregateException : One or more errors occurred.* ---> System.NotImplementedException : Not implemented yet ---> System.Exception : other at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<ThrowSampleExceptionAsync>[^\n]* --- End of stack trace from previous location where exception was thrown --- \s*at System.Runtime.[^\n]+.Throw[^\n]* (at System.Runtime.CompilerServices.TaskAwaiter.[^\n]* )+at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<HandleInnerException>[^\n]* --- End of stack trace from previous location where exception was thrown --- \s*at System.Runtime.[^\n]+.Throw[^\n]* (at System.Runtime.CompilerServices.TaskAwaiter.[^\n]* )+at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<WrapInnerExceptionLevel2>[^\n]* --- End of stack trace from previous location where exception was thrown --- \s*at System.Runtime.[^\n]+.Throw[^\n]* (at System.Runtime.CompilerServices.TaskAwaiter.[^\n]* )+at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<WrapInnerExceptionLevel1>[^\n]* --- End of stack trace from previous location where exception was thrown --- \s*at System.Runtime.[^\n]+.Throw[^\n]* (at System.Runtime.CompilerServices.TaskAwaiter.[^\n]* )+at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<MakeSampleException>[^\n]*$"; var formattedDetails = new DefaultExceptionFormatter().WithAllMembersIncludedOnStackTrace().Format(exception); Assert.That(formattedDetails.Replace("\r", ""), Does.Match(expectedExceptionDetails.Replace("\r", ""))); }
/// <summary> /// Create options with default values. /// </summary> public ElmahIoOptions() { ExceptionFormatter = new DefaultExceptionFormatter(); HandledStatusCodesToLog = new List <int> { 404 }; }
public async Task Format_should_format_exception_with_8_lines_of_stack_trace_by_default() { var exception = await MakeSampleException(); var formattedDetails = new DefaultExceptionFormatter().Format(exception); var stackTraceLinesNumber = formattedDetails .Split('\n') .AsEnumerable() .Count(l => l.StartsWith("at ") || l.StartsWith("---")); Assert.That(stackTraceLinesNumber, Is.EqualTo(8)); }
public async Task Format_should_format_exception_with_customized_number_of_stack_trace_lines() { var exception = await MakeSampleException(); var expectedExceptionDetails = @"^System.Exception : ThrowSampleExceptionAsync ---> System.InvalidOperationException : ThrowInnerExceptionAsync ---> System.AggregateException : One or more errors occurred\..* ---> System.NotImplementedException : Not implemented yet ---> System.Exception : other at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<ThrowSampleExceptionAsync>[^\n]* --- End of stack trace from previous location where exception was thrown ---$"; var formattedDetails = new DefaultExceptionFormatter().WithStackTraceLinesLimit(2).Format(exception); Assert.That(formattedDetails.Replace("\r", ""), Does.Match(expectedExceptionDetails.Replace("\r", ""))); }
public async Task Format_should_format_exception_with_filtered_lines() { var exception = await MakeSampleException(); var expectedExceptionDetails = @"^System.Exception : ThrowSampleExceptionAsync ---> System.InvalidOperationException : ThrowInnerExceptionAsync ---> System.AggregateException : One or more errors occurred.* ---> System.NotImplementedException : Not implemented yet ---> System.Exception : other at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests[^\n]+ThrowSampleExceptionAsync[^\n]+ at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests[^\n]+MakeSampleException[^\n]+$"; var formattedDetails = new DefaultExceptionFormatter() .WithMembersExcludedFromStackTrace("System.Runtime.*", ".*RecurrentCall.*") .Format(exception); Assert.That(formattedDetails.Replace("\r", ""), Does.Match(expectedExceptionDetails.Replace("\r", ""))); }
public async Task Format_should_format_exception_with_filtered_lines() { var exception = await MakeSampleException(); var expectedExceptionDetails = @"^System.Exception : ThrowSampleExceptionAsync ---> System.InvalidOperationException : ThrowInnerExceptionAsync ---> System.AggregateException : One or more errors occurred\..* ---> System.NotImplementedException : Not implemented yet ---> System.Exception : other at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<ThrowSampleExceptionAsync>[^\n]* --- End of stack trace from previous location where exception was thrown --- at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<HandleInnerException>[^\n]* --- End of stack trace from previous location where exception was thrown --- at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<WrapInnerExceptionLevel2>[^\n]* --- End of stack trace from previous location where exception was thrown --- at LightBDD.Core.UnitTests.Formatting.ExceptionFormatting.DefaultExceptionFormatter_tests.<WrapInnerExceptionLevel1>[^\n]* --- End of stack trace from previous location where exception was thrown ---$"; var formattedDetails = new DefaultExceptionFormatter() .WithMembersExcludedFromStackTrace("System.Runtime.*") .Format(exception); Assert.That(formattedDetails.Replace("\r", ""), Does.Match(expectedExceptionDetails.Replace("\r", ""))); }
/// <summary> /// Adds Fixie specific stack trace member exclusions. /// </summary> /// <param name="formatter">Formatter.</param> /// <returns>Formatter.</returns> public static DefaultExceptionFormatter WithTestFrameworkDefaults(this DefaultExceptionFormatter formatter) { return(formatter); }
/// <summary> /// Adds NUnit specific stack trace member exclusions. /// </summary> /// <param name="formatter">Formatter.</param> /// <returns>Formatter.</returns> public static DefaultExceptionFormatter WithTestFrameworkDefaults(this DefaultExceptionFormatter formatter) { return(formatter.WithMembersExcludedFromStackTrace("NUnit\\..*")); }
/// <summary> /// Adds MsTest specific stack trace member exclusions. /// </summary> /// <param name="formatter">Formatter.</param> /// <returns>Formatter.</returns> public static DefaultExceptionFormatter WithTestFrameworkDefaults(this DefaultExceptionFormatter formatter) { return(formatter .WithMembersExcludedFromStackTrace("Microsoft\\.VisualStudio\\.TestTools\\..*")); }