mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 02:22:55 +08:00
Update detach test to assert correct behaviour
This commit is contained in:
parent
51d6db1bca
commit
509301d94f
@ -43,39 +43,35 @@ namespace osu.Game.Tests.Database
|
|||||||
using (var importer = new BeatmapModelManager(realmFactory, storage))
|
using (var importer = new BeatmapModelManager(realmFactory, storage))
|
||||||
using (new RulesetStore(realmFactory, storage))
|
using (new RulesetStore(realmFactory, storage))
|
||||||
{
|
{
|
||||||
ILive<BeatmapSetInfo>? imported;
|
ILive<BeatmapSetInfo>? beatmapSet;
|
||||||
|
|
||||||
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
|
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
|
||||||
imported = await importer.Import(reader);
|
beatmapSet = await importer.Import(reader);
|
||||||
|
|
||||||
Assert.NotNull(imported);
|
Assert.NotNull(beatmapSet);
|
||||||
Debug.Assert(imported != null);
|
Debug.Assert(beatmapSet != null);
|
||||||
|
|
||||||
BeatmapSetInfo? detached = null;
|
BeatmapSetInfo? detachedBeatmapSet = null;
|
||||||
|
|
||||||
imported.PerformRead(live =>
|
beatmapSet.PerformRead(live =>
|
||||||
{
|
{
|
||||||
var timer = new Stopwatch();
|
detachedBeatmapSet = live.Detach();
|
||||||
timer.Start();
|
|
||||||
detached = live.Detach();
|
|
||||||
Logger.Log($"Detach took {timer.ElapsedMilliseconds} ms");
|
|
||||||
|
|
||||||
Logger.Log($"NamedFiles: {live.Files.Count} {detached.Files.Count}");
|
Assert.AreEqual(live.Files.Count, detachedBeatmapSet.Files.Count);
|
||||||
Logger.Log($"Files: {live.Files.Select(f => f.File).Count()} {detached.Files.Select(f => f.File).Count()}");
|
Assert.AreEqual(live.Files.Select(f => f.File).Count(), detachedBeatmapSet.Files.Select(f => f.File).Count());
|
||||||
Logger.Log($"Difficulties: {live.Beatmaps.Count} {detached.Beatmaps.Count}");
|
Assert.AreEqual(live.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count);
|
||||||
Logger.Log($"BeatmapDifficulties: {live.Beatmaps.Select(f => f.Difficulty).Count()} {detached.Beatmaps.Select(f => f.Difficulty).Count()}");
|
Assert.AreEqual(live.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
|
||||||
Logger.Log($"Metadata: {live.Metadata} {detached.Metadata}");
|
Assert.AreEqual(live.Metadata, detachedBeatmapSet.Metadata);
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger.Log("Testing detached-ness");
|
Debug.Assert(detachedBeatmapSet != null);
|
||||||
|
|
||||||
Debug.Assert(detached != null);
|
// Check detached instances can all be accessed without throwing.
|
||||||
|
Assert.NotNull(detachedBeatmapSet.Files.Count);
|
||||||
Logger.Log($"NamedFiles: {detached.Files.Count}");
|
Assert.NotZero(detachedBeatmapSet.Files.Select(f => f.File).Count());
|
||||||
Logger.Log($"Files: {detached.Files.Select(f => f.File).Count()}");
|
Assert.NotNull(detachedBeatmapSet.Beatmaps.Count);
|
||||||
Logger.Log($"Difficulties: {detached.Beatmaps.Count}");
|
Assert.NotZero(detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count());
|
||||||
Logger.Log($"BeatmapDifficulties: {detached.Beatmaps.Select(f => f.Difficulty).Count()}");
|
Assert.NotNull(detachedBeatmapSet.Metadata);
|
||||||
Logger.Log($"Metadata: {detached.Metadata}");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user