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:
parent
2e774fbc2b
commit
87f6f74795
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user