Skip to content

Commit

Permalink
need this for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsandfoxes committed Dec 12, 2024
1 parent e8e9652 commit 7dd2cbd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/Sentry.Unity.Android.Tests/SentryNativeAndroidTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SentryNativeAndroidTests
private Action _fakeReinstallSentryNativeBackendStrategy;
private TestUnityInfo _sentryUnityInfo = null!;
private TestSentryJava _testSentryJava = null!;
private TestLogger _logger = new();
private TestLogger _logger = null!;
private SentryUnityOptions _options = null!;

public SentryNativeAndroidTests()
Expand All @@ -28,10 +28,11 @@ public void SetUp()
_reinstallCalled = false;
_sentryUnityInfo = new TestUnityInfo { IL2CPP = false };

SentryNativeAndroid.JniExecutor ??= new JniExecutor(_logger);
SentryNativeAndroid.JniExecutor = new TestJniExecutor();
_testSentryJava = new TestSentryJava();
SentryNativeAndroid.SentryJava = _testSentryJava;

_logger = new TestLogger();
_options = new SentryUnityOptions
{
Debug = true,
Expand All @@ -41,12 +42,10 @@ public void SetUp()
}

[TearDown]
public void TearDown()
{
public void TearDown() =>
_fakeReinstallSentryNativeBackendStrategy =
Interlocked.Exchange(ref SentryNative.ReinstallSentryNativeBackendStrategy!,
_originalReinstallSentryNativeBackendStrategy)!;
}

[Test]
public void Configure_DefaultConfiguration_SetsScopeObserver()
Expand Down
20 changes: 20 additions & 0 deletions test/Sentry.Unity.Android.Tests/TestJniExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;

namespace Sentry.Unity.Android.Tests;

public class TestJniExecutor : IJniExecutor
{
public TResult? Run<TResult>(Func<TResult?> jniOperation, TimeSpan? timeout = null)
{
return default;
}

public void Run(Action jniOperation, TimeSpan? timeout = null)
{
}

public void Dispose()
{
// TODO release managed resources here
}
}

0 comments on commit 7dd2cbd

Please sign in to comment.