Skip to content

Commit fb8bdc7

Browse files
committed
Test
1 parent d74c044 commit fb8bdc7

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/Sentry.Tests/SentrySdkTests.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,47 @@ public void ProcessOnBeforeSend_NativeErrorSuppression(bool suppressNativeErrors
10411041
}
10421042
}
10431043

1044+
[Theory]
1045+
[InlineData(true)]
1046+
[InlineData(false)]
1047+
public void ProcessOnBeforeSend_NativeErrorSuppressionBeforeHubInit(bool suppressNativeErrors)
1048+
{
1049+
// Arrange
1050+
var options = new SentryOptions
1051+
{
1052+
Dsn = ValidDsn,
1053+
DiagnosticLogger = _logger,
1054+
IsGlobalModeEnabled = true,
1055+
Debug = true,
1056+
AutoSessionTracking = false,
1057+
BackgroundWorker = Substitute.For<IBackgroundWorker>(),
1058+
InitNativeSdks = false,
1059+
};
1060+
options.Native.SuppressExcBadAccess = suppressNativeErrors;
1061+
1062+
var scope = new Scope(options);
1063+
// `SIGABRT` must be filtered out early on startup during
1064+
// the Cocoa SDK init before the Hub instance has been created
1065+
var hub = DisabledHub.Instance;
1066+
1067+
var evt = new Sentry.CocoaSdk.SentryEvent();
1068+
var ex = new Sentry.CocoaSdk.SentryException("Not checked", "EXC_BAD_ACCESS");
1069+
evt.Exceptions = [ex];
1070+
1071+
// Act
1072+
var result = SentrySdk.ProcessOnBeforeSend(options, evt, hub);
1073+
1074+
// Assert
1075+
if (suppressNativeErrors)
1076+
{
1077+
result.Should().BeNull();
1078+
}
1079+
else
1080+
{
1081+
result.Exceptions.First().Type.Should().Be("EXC_BAD_ACCESS");
1082+
}
1083+
}
1084+
10441085
[Fact]
10451086
public void ProcessOnBeforeSend_OptionsBeforeOnSendRuns()
10461087
{

0 commit comments

Comments
 (0)