Skip to content

Commit

Permalink
Add failing test showing realm not sending through null ChangeSet
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 9, 2024
1 parent c100d1a commit c8b9c11
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions osu.Game.Tests/Database/RealmSubscriptionRegistrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,35 @@ void onChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet? changes)
}
}

[Test]
public void TestSubscriptionInitialChangeSetNull()
{
ChangeSet? firstChanges = null;
int receivedChangesCount = 0;

RunTestWithRealm((realm, _) =>
{
var registration = realm.RegisterForNotifications(r => r.All<BeatmapSetInfo>(), onChanged);

realm.WriteAsync(r => r.Add(TestResources.CreateTestBeatmapSetInfo())).WaitSafely();

realm.Run(r => r.Refresh());

Assert.That(receivedChangesCount, Is.EqualTo(2));
Assert.That(firstChanges, Is.Null);

registration.Dispose();
});

void onChanged(IRealmCollection<BeatmapSetInfo> sender, ChangeSet? changes)
{
if (receivedChangesCount == 0)
firstChanges = changes;

receivedChangesCount++;
}
}

[Test]
public void TestSubscriptionWithAsyncWrite()
{
Expand Down

0 comments on commit c8b9c11

Please sign in to comment.