Skip to content

Commit 90ede6b

Browse files
Fixed mobile tests
1 parent d6dd817 commit 90ede6b

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/Sentry/Internal/CacheDirectoryCoordinator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ internal static class CacheDirectoryHelper
127127
? null
128128
: Path.Combine(options.CacheDirectoryPath, "Sentry");
129129

130-
private static string? GetIsolatedFolderName(this SentryOptions options)
130+
internal static string? GetIsolatedFolderName(this SentryOptions options)
131131
{
132132
var stringBuilder = new StringBuilder(IsolatedCacheDirectoryPrefix);
133133
#if IOS || ANDROID

test/Sentry.Tests/SentryOptionsTests.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -683,17 +683,28 @@ public void TryGetIsolatedCacheDirectoryPath_NullCacheDirectory_ReturnsNull()
683683
Assert.Null(o.TryGetIsolatedCacheDirectoryPath());
684684
}
685685

686+
#if IOS || ANDROID
686687
[Fact]
687-
public void TryGetIsolatedCacheDirectoryPath_MissingDsn_ReturnsNull()
688+
public void GetIsolatedFolderName_MissingDsn_UniquewForInitcount()
688689
{
689690
var o = new SentryOptions { CacheDirectoryPath = "c:\\cache", Dsn = null };
690-
Assert.Null(o.TryGetIsolatedCacheDirectoryPath());
691+
var folder =o.GetIsolatedFolderName();
692+
Assert.Equal($"{CacheDirectoryHelper.IsolatedCacheDirectoryPrefix}{o.InitCounter.Count}", folder);
693+
}
694+
#else
695+
[Fact]
696+
public void GetIsolatedFolderName_MissingDsn__ReturnsNull()
697+
{
698+
var o = new SentryOptions { CacheDirectoryPath = "c:\\cache", Dsn = null };
699+
var folder= o.GetIsolatedFolderName();
700+
Assert.Null(folder);
691701
}
702+
#endif
692703

693704
[Theory]
694705
[InlineData(5, null)]
695706
[InlineData(5, 7)]
696-
public void TryGetIsolatedCacheDirectoryPath_UniqueForDsnInitCountAndProcessIdUnlessMobile(int initCount, int? processId)
707+
public void GetIsolatedFolderName_UniqueForDsnInitCountAndProcessId(int initCount, int? processId)
697708
{
698709
// Arrange
699710
var initCounter = Substitute.For<IInitCounter>();
@@ -707,14 +718,14 @@ public void TryGetIsolatedCacheDirectoryPath_UniqueForDsnInitCountAndProcessIdUn
707718
};
708719

709720
// Act
710-
var path = o.TryGetIsolatedCacheDirectoryPath();
721+
var path = o.GetIsolatedFolderName();
711722

712723
// Assert
713724
#if IOS || ANDROID
714-
var expectedFolder = "Sentry";
725+
var expectedFolder = $"{CacheDirectoryHelper.IsolatedCacheDirectoryPrefix}{initCount}";
715726
#else
716-
var expectedFolder = $"{ValidDsn.GetHashString()}_{processId ?? 0}_{initCount}";
727+
var expectedFolder = $"{CacheDirectoryHelper.IsolatedCacheDirectoryPrefix}{ValidDsn.GetHashString()}_{processId ?? 0}_{initCount}";
717728
#endif
718-
path.Should().EndWith(expectedFolder);
729+
path.Should().Be(expectedFolder);
719730
}
720731
}

0 commit comments

Comments
 (0)