@@ -590,7 +590,8 @@ public void OnException_WhenTracerCaptureErrorEnvironmentVariableIsTrue_Captures
590
590
configurations . Setup ( c => c . TracerCaptureError ) . Returns ( true ) ;
591
591
var recorder = new Mock < IXRayRecorder > ( ) ;
592
592
var exception = new Exception ( "Test Exception" ) ;
593
-
593
+ var message = GetException ( exception ) ;
594
+
594
595
var handler = new TracingAspectHandler ( null , nameSpace , TracingCaptureMode . EnvironmentVariable ,
595
596
configurations . Object , recorder . Object ) ;
596
597
var eventArgs = new AspectEventArgs { Name = methodName } ;
@@ -604,7 +605,7 @@ public void OnException_WhenTracerCaptureErrorEnvironmentVariableIsTrue_Captures
604
605
v . AddMetadata (
605
606
It . Is < string > ( i => i == nameSpace ) ,
606
607
It . Is < string > ( i => i == $ "{ methodName } error") ,
607
- It . Is < Exception > ( i => i == exception
608
+ It . Is < string > ( i => i == message
608
609
)
609
610
) , Times . Once ) ;
610
611
}
@@ -650,7 +651,8 @@ public void OnException_WhenTracerCaptureModeIsError_CapturesError()
650
651
configurations . Setup ( c => c . TracingDisabled ) . Returns ( false ) ;
651
652
var recorder = new Mock < IXRayRecorder > ( ) ;
652
653
var exception = new Exception ( "Test Exception" ) ;
653
-
654
+ var message = GetException ( exception ) ;
655
+
654
656
var handler = new TracingAspectHandler ( null , nameSpace , TracingCaptureMode . Error ,
655
657
configurations . Object , recorder . Object ) ;
656
658
var eventArgs = new AspectEventArgs { Name = methodName } ;
@@ -664,7 +666,7 @@ public void OnException_WhenTracerCaptureModeIsError_CapturesError()
664
666
v . AddMetadata (
665
667
It . Is < string > ( i => i == nameSpace ) ,
666
668
It . Is < string > ( i => i == $ "{ methodName } error") ,
667
- It . Is < Exception > ( i => i == exception
669
+ It . Is < string > ( i => i == message
668
670
)
669
671
) , Times . Once ) ;
670
672
}
@@ -680,7 +682,8 @@ public void OnException_WhenTracerCaptureModeIsResponseAndError_CapturesError()
680
682
configurations . Setup ( c => c . TracingDisabled ) . Returns ( false ) ;
681
683
var recorder = new Mock < IXRayRecorder > ( ) ;
682
684
var exception = new Exception ( "Test Exception" ) ;
683
-
685
+ var message = GetException ( exception ) ;
686
+
684
687
var handler = new TracingAspectHandler ( null , nameSpace , TracingCaptureMode . ResponseAndError ,
685
688
configurations . Object , recorder . Object ) ;
686
689
var eventArgs = new AspectEventArgs { Name = methodName } ;
@@ -694,7 +697,7 @@ public void OnException_WhenTracerCaptureModeIsResponseAndError_CapturesError()
694
697
v . AddMetadata (
695
698
It . Is < string > ( i => i == nameSpace ) ,
696
699
It . Is < string > ( i => i == $ "{ methodName } error") ,
697
- It . Is < Exception > ( i => i == exception
700
+ It . Is < string > ( i => i == message
698
701
)
699
702
) , Times . Once ) ;
700
703
}
@@ -761,6 +764,27 @@ public void OnException_WhenTracerCaptureModeIsDisabled_DoesNotCaptureError()
761
764
762
765
#endregion
763
766
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
+
764
788
#region OnExit Tests
765
789
766
790
[ Fact ]
0 commit comments