Skip to content

Commit 5bfa71a

Browse files
committed
test: use TestAccessor pattern
1 parent a2c61d4 commit 5bfa71a

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

src/Sentry.Android.AssemblyReader/V2/AssemblyStoreReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected AssemblyStoreReader(Stream store, string path, DebugLogger? logger)
4545

4646
protected BinaryReader CreateReader() => new BinaryReader(StoreStream, ReaderEncoding, leaveOpen: true);
4747

48-
protected internal abstract bool IsSupported();
48+
protected abstract bool IsSupported();
4949
protected abstract void Prepare();
5050
protected abstract ulong GetStoreStartDataOffset();
5151

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Sentry.Android.AssemblyReader.V2;
2+
3+
internal partial class StoreReader
4+
{
5+
internal TestAccessor GetTestAccessor()
6+
=> new(this);
7+
8+
internal readonly struct TestAccessor
9+
{
10+
private readonly StoreReader _instance;
11+
12+
internal TestAccessor(StoreReader instance)
13+
{
14+
_instance = instance;
15+
}
16+
17+
internal bool IsSupported() => _instance.IsSupported();
18+
}
19+
}

src/Sentry.Android.AssemblyReader/V2/StoreReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public StoreReader(Stream store, string path, DebugLogger? logger)
9191

9292
protected override ulong GetStoreStartDataOffset() => elfOffset;
9393

94-
protected internal override bool IsSupported()
94+
protected override bool IsSupported()
9595
{
9696
lock (StreamLock)
9797
{

test/Sentry.Android.AssemblyReader.Tests/StoreReaderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public void IsSupported_Concurrent_IsThreadSafe()
1313
var storeReader = new StoreReader(memoryStream, "testStore", null);
1414

1515
// Act
16-
var result = Parallel.For(0, 10, _ => storeReader.IsSupported());
16+
var result = Parallel.For(0, 10, _ => storeReader.GetTestAccessor().IsSupported());
1717

1818
// Test passes if no exceptions are thrown, but we can also assert completion
1919
result.IsCompleted.Should().BeTrue();

0 commit comments

Comments
 (0)