@@ -590,7 +590,8 @@ public void OnException_WhenTracerCaptureErrorEnvironmentVariableIsTrue_Captures
590590 configurations . Setup ( c => c . TracerCaptureError ) . Returns ( true ) ;
591591 var recorder = new Mock < IXRayRecorder > ( ) ;
592592 var exception = new Exception ( "Test Exception" ) ;
593-
593+ var message = GetException ( exception ) ;
594+
594595 var handler = new TracingAspectHandler ( null , nameSpace , TracingCaptureMode . EnvironmentVariable ,
595596 configurations . Object , recorder . Object ) ;
596597 var eventArgs = new AspectEventArgs { Name = methodName } ;
@@ -604,7 +605,7 @@ public void OnException_WhenTracerCaptureErrorEnvironmentVariableIsTrue_Captures
604605 v . AddMetadata (
605606 It . Is < string > ( i => i == nameSpace ) ,
606607 It . Is < string > ( i => i == $ "{ methodName } error") ,
607- It . Is < Exception > ( i => i == exception
608+ It . Is < string > ( i => i == message
608609 )
609610 ) , Times . Once ) ;
610611 }
@@ -650,7 +651,8 @@ public void OnException_WhenTracerCaptureModeIsError_CapturesError()
650651 configurations . Setup ( c => c . TracingDisabled ) . Returns ( false ) ;
651652 var recorder = new Mock < IXRayRecorder > ( ) ;
652653 var exception = new Exception ( "Test Exception" ) ;
653-
654+ var message = GetException ( exception ) ;
655+
654656 var handler = new TracingAspectHandler ( null , nameSpace , TracingCaptureMode . Error ,
655657 configurations . Object , recorder . Object ) ;
656658 var eventArgs = new AspectEventArgs { Name = methodName } ;
@@ -664,7 +666,7 @@ public void OnException_WhenTracerCaptureModeIsError_CapturesError()
664666 v . AddMetadata (
665667 It . Is < string > ( i => i == nameSpace ) ,
666668 It . Is < string > ( i => i == $ "{ methodName } error") ,
667- It . Is < Exception > ( i => i == exception
669+ It . Is < string > ( i => i == message
668670 )
669671 ) , Times . Once ) ;
670672 }
@@ -680,7 +682,8 @@ public void OnException_WhenTracerCaptureModeIsResponseAndError_CapturesError()
680682 configurations . Setup ( c => c . TracingDisabled ) . Returns ( false ) ;
681683 var recorder = new Mock < IXRayRecorder > ( ) ;
682684 var exception = new Exception ( "Test Exception" ) ;
683-
685+ var message = GetException ( exception ) ;
686+
684687 var handler = new TracingAspectHandler ( null , nameSpace , TracingCaptureMode . ResponseAndError ,
685688 configurations . Object , recorder . Object ) ;
686689 var eventArgs = new AspectEventArgs { Name = methodName } ;
@@ -694,7 +697,7 @@ public void OnException_WhenTracerCaptureModeIsResponseAndError_CapturesError()
694697 v . AddMetadata (
695698 It . Is < string > ( i => i == nameSpace ) ,
696699 It . Is < string > ( i => i == $ "{ methodName } error") ,
697- It . Is < Exception > ( i => i == exception
700+ It . Is < string > ( i => i == message
698701 )
699702 ) , Times . Once ) ;
700703 }
@@ -761,6 +764,27 @@ public void OnException_WhenTracerCaptureModeIsDisabled_DoesNotCaptureError()
761764
762765 #endregion
763766
767+ #region Utilities
768+
769+ static string GetException ( Exception exception )
770+ {
771+ var message =
772+ "Exception type " + exception . GetType ( ) + Environment . NewLine +
773+ "Exception message: " + exception . Message + Environment . NewLine +
774+ "Stack trace: " + exception . StackTrace + Environment . NewLine ;
775+ if ( exception . InnerException != null )
776+ {
777+ message += "---BEGIN InnerException--- " + Environment . NewLine +
778+ "Exception type " + exception . InnerException . GetType ( ) + Environment . NewLine +
779+ "Exception message: " + exception . InnerException . Message + Environment . NewLine +
780+ "Stack trace: " + exception . InnerException . StackTrace + Environment . NewLine +
781+ "---END Inner Exception" ;
782+ }
783+ return message ;
784+ }
785+
786+ #endregion
787+
764788 #region OnExit Tests
765789
766790 [ Fact ]
0 commit comments