1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:02:55 +08:00

Add test coverage of upgrade success for good measure

This commit is contained in:
Dean Herbert 2023-07-26 16:28:38 +09:00
parent a2f1ced5a2
commit 235cb2d73f

View File

@ -127,6 +127,30 @@ namespace osu.Game.Tests.Database
});
}
[Test]
public void TestScoreUpgradeSuccess()
{
ScoreInfo scoreInfo = null!;
AddStep("Add score which requires upgrade (but has no beatmap)", () =>
{
Realm.Write(r =>
{
r.Add(scoreInfo = new ScoreInfo(ruleset: r.All<RulesetInfo>().First(), beatmap: r.All<BeatmapInfo>().First())
{
TotalScoreVersion = 30000002,
LegacyTotalScore = 123456,
IsLegacyScore = true,
});
});
});
AddStep("Run background processor", () => Add(new TestBackgroundDataStoreProcessor()));
AddUntilStep("Score version upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(LegacyScoreEncoder.LATEST_VERSION));
AddAssert("Score not marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreUpgradeFailed), () => Is.False);
}
[Test]
public void TestScoreUpgradeFailed()
{
@ -150,7 +174,8 @@ namespace osu.Game.Tests.Database
AddStep("Run background processor", () => Add(new TestBackgroundDataStoreProcessor()));
AddUntilStep("Score marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreUpgradeFailed));
AddUntilStep("Score marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreUpgradeFailed), () => Is.True);
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000002));
}
public partial class TestBackgroundDataStoreProcessor : BackgroundDataStoreProcessor