mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 12:58:01 +09:00
Add test coverage of stores stored in database as well
This commit is contained in:
parent
d4d985ba0f
commit
38031fdf23
@ -84,16 +84,16 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
clearScores();
|
clearScores();
|
||||||
checkCount(0);
|
checkDisplayedCount(0);
|
||||||
|
|
||||||
importMoreScores(() => beatmapInfo);
|
importMoreScores(() => beatmapInfo);
|
||||||
checkCount(10);
|
checkDisplayedCount(10);
|
||||||
|
|
||||||
importMoreScores(() => beatmapInfo);
|
importMoreScores(() => beatmapInfo);
|
||||||
checkCount(20);
|
checkDisplayedCount(20);
|
||||||
|
|
||||||
clearScores();
|
clearScores();
|
||||||
checkCount(0);
|
checkDisplayedCount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
clearScores();
|
clearScores();
|
||||||
checkCount(0);
|
checkDisplayedCount(0);
|
||||||
|
|
||||||
AddStep(@"Perform initial save to guarantee stable hash", () =>
|
AddStep(@"Perform initial save to guarantee stable hash", () =>
|
||||||
{
|
{
|
||||||
@ -124,7 +124,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
importMoreScores(() => beatmapInfo);
|
importMoreScores(() => beatmapInfo);
|
||||||
checkCount(10);
|
|
||||||
|
checkDisplayedCount(10);
|
||||||
|
checkStoredCount(10);
|
||||||
|
|
||||||
AddStep(@"Save with changes", () =>
|
AddStep(@"Save with changes", () =>
|
||||||
{
|
{
|
||||||
@ -134,11 +136,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("Hash changed", () => beatmapInfo.Hash, () => Is.Not.EqualTo(originalHash));
|
AddAssert("Hash changed", () => beatmapInfo.Hash, () => Is.Not.EqualTo(originalHash));
|
||||||
checkCount(0);
|
checkDisplayedCount(0);
|
||||||
|
checkStoredCount(10);
|
||||||
|
|
||||||
importMoreScores(() => beatmapInfo);
|
importMoreScores(() => beatmapInfo);
|
||||||
importMoreScores(() => beatmapInfo);
|
importMoreScores(() => beatmapInfo);
|
||||||
checkCount(20);
|
checkDisplayedCount(20);
|
||||||
|
checkStoredCount(30);
|
||||||
|
|
||||||
AddStep(@"Revert changes", () =>
|
AddStep(@"Revert changes", () =>
|
||||||
{
|
{
|
||||||
@ -148,10 +152,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("Hash restored", () => beatmapInfo.Hash, () => Is.EqualTo(originalHash));
|
AddAssert("Hash restored", () => beatmapInfo.Hash, () => Is.EqualTo(originalHash));
|
||||||
checkCount(10);
|
checkDisplayedCount(10);
|
||||||
|
checkStoredCount(30);
|
||||||
|
|
||||||
clearScores();
|
clearScores();
|
||||||
checkCount(0);
|
checkDisplayedCount(0);
|
||||||
|
checkStoredCount(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -234,9 +240,12 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("Clear all scores", () => scoreManager.Delete());
|
AddStep("Clear all scores", () => scoreManager.Delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCount(int expected) =>
|
private void checkDisplayedCount(int expected) =>
|
||||||
AddUntilStep($"{expected} scores displayed", () => leaderboard.ChildrenOfType<LeaderboardScore>().Count(), () => Is.EqualTo(expected));
|
AddUntilStep($"{expected} scores displayed", () => leaderboard.ChildrenOfType<LeaderboardScore>().Count(), () => Is.EqualTo(expected));
|
||||||
|
|
||||||
|
private void checkStoredCount(int expected) =>
|
||||||
|
AddUntilStep($"Total scores stored is {expected}", () => Realm.Run(r => r.All<ScoreInfo>().Count(s => !s.DeletePending)), () => Is.EqualTo(expected));
|
||||||
|
|
||||||
private static ScoreInfo[] generateSampleScores(BeatmapInfo beatmapInfo)
|
private static ScoreInfo[] generateSampleScores(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user