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", ""))); }
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", ""))); }