@@ -996,6 +996,7 @@ public void InitHub_DebugEnabled_DebugLogsLogged()
996996 [ InlineData ( false ) ]
997997 public void ProcessOnBeforeSend_NativeErrorSuppression ( bool suppressNativeErrors )
998998 {
999+ // Arrange
9991000 var options = new SentryOptions
10001001 {
10011002 Dsn = ValidDsn ,
@@ -1014,11 +1015,20 @@ public void ProcessOnBeforeSend_NativeErrorSuppression(bool suppressNativeErrors
10141015 called = true ;
10151016 return e ;
10161017 } ) ;
1018+
1019+ var scope = new Scope ( options ) ;
1020+ var hub = Substitute . For < IHub > ( ) ;
1021+ hub . When ( h => hub . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
1022+ . Do ( callback => callback . Arg < Action < Scope > > ( ) . Invoke ( scope ) ) ;
1023+
10171024 var evt = new Sentry . CocoaSdk . SentryEvent ( ) ;
10181025 var ex = new Sentry . CocoaSdk . SentryException ( "Not checked" , "EXC_BAD_ACCESS" ) ;
10191026 evt . Exceptions = [ ex ] ;
1020- var result = SentrySdk . ProcessOnBeforeSend ( options , evt ) ;
10211027
1028+ // Act
1029+ var result = SentrySdk . ProcessOnBeforeSend ( options , evt , hub ) ;
1030+
1031+ // Assert
10221032 if ( suppressNativeErrors )
10231033 {
10241034 called . Should ( ) . BeFalse ( ) ;
@@ -1034,6 +1044,7 @@ public void ProcessOnBeforeSend_NativeErrorSuppression(bool suppressNativeErrors
10341044 [ Fact ]
10351045 public void ProcessOnBeforeSend_OptionsBeforeOnSendRuns ( )
10361046 {
1047+ // Arrange
10371048 var options = new SentryOptions
10381049 {
10391050 Dsn = ValidDsn ,
@@ -1052,20 +1063,69 @@ public void ProcessOnBeforeSend_OptionsBeforeOnSendRuns()
10521063 native . ReleaseName = "release name" ;
10531064 native . Environment = "environment" ;
10541065 native . Transaction = "transaction name" ;
1055-
10561066 options . SetBeforeSend ( e =>
10571067 {
10581068 e . TransactionName = "dotnet" ;
10591069 return e ;
10601070 } ) ;
1061- var result = SentrySdk . ProcessOnBeforeSend ( options , native ) ;
1071+
1072+ var scope = new Scope ( options ) ;
1073+ var hub = Substitute . For < IHub > ( ) ;
1074+ hub . When ( h => hub . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
1075+ . Do ( callback => callback . Arg < Action < Scope > > ( ) . Invoke ( scope ) ) ;
1076+
1077+ // Act
1078+ var result = SentrySdk . ProcessOnBeforeSend ( options , native , hub ) ;
1079+
1080+ // Assert
10621081 result . Should ( ) . NotBeNull ( ) ;
10631082 result . Transaction . Should ( ) . Be ( "dotnet" ) ;
10641083 }
1084+
1085+ [ Fact ]
1086+ public void ProcessOnBeforeSend_EventProcessorsInvoked ( )
1087+ {
1088+ // Arrange
1089+ var options = new SentryOptions
1090+ {
1091+ Dsn = ValidDsn ,
1092+ DiagnosticLogger = _logger ,
1093+ IsGlobalModeEnabled = true ,
1094+ Debug = true ,
1095+ AutoSessionTracking = false ,
1096+ BackgroundWorker = Substitute . For < IBackgroundWorker > ( ) ,
1097+ InitNativeSdks = false ,
1098+ } ;
1099+ var eventProcessor = new TestEventProcessor ( ) ;
1100+ options . AddEventProcessor ( eventProcessor ) ;
1101+
1102+ var scope = new Scope ( options ) ;
1103+ var hub = Substitute . For < IHub > ( ) ;
1104+ hub . When ( h => hub . ConfigureScope ( Arg . Any < Action < Scope > > ( ) ) )
1105+ . Do ( callback => callback . Arg < Action < Scope > > ( ) . Invoke ( scope ) ) ;
1106+
1107+ var native = new Sentry . CocoaSdk . SentryEvent ( ) ;
1108+
1109+ // Act
1110+ SentrySdk . ProcessOnBeforeSend ( options , native , hub ) ;
1111+
1112+ // Assert
1113+ eventProcessor . Invoked . Should ( ) . BeTrue ( ) ;
1114+ }
10651115#endif
10661116
10671117 public void Dispose ( )
10681118 {
10691119 SentrySdk . Close ( ) ;
10701120 }
10711121}
1122+
1123+ file class TestEventProcessor : ISentryEventProcessor
1124+ {
1125+ public bool Invoked { get ; private set ; }
1126+ public SentryEvent Process ( SentryEvent @event )
1127+ {
1128+ Invoked = true ;
1129+ return @event ;
1130+ }
1131+ }
0 commit comments