1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Add failing test coverage of adding a file to a detached beatmap across threads

This commit is contained in:
Dean Herbert 2022-05-10 21:03:55 +09:00
parent 2e774fbc2b
commit 87f6f74795

View File

@ -136,6 +136,37 @@ namespace osu.Game.Tests.Database
});
}
[Test]
public void TestAddFileToAsyncImportedBeatmap()
{
RunTestWithRealm((realm, storage) =>
{
BeatmapSetInfo? detachedSet = null;
using (var importer = new BeatmapModelManager(realm, storage))
using (new RealmRulesetStore(realm, storage))
{
Task.Run(async () =>
{
Live<BeatmapSetInfo>? beatmapSet;
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
// ReSharper disable once AccessToDisposedClosure
beatmapSet = await importer.Import(reader);
Assert.NotNull(beatmapSet);
Debug.Assert(beatmapSet != null);
// Intentionally detach on async thread as to not trigger a refresh on the main thread.
beatmapSet.PerformRead(s => detachedSet = s.Detach());
}).WaitSafely();
Debug.Assert(detachedSet != null);
importer.AddFile(detachedSet, new MemoryStream(), "test");
}
});
}
[Test]
public void TestImportBeatmapThenCleanup()
{