public void TestMapWithKnownMapper() { var author = new RealmUser { Username = "******" }; AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(author)))); }
public void TestUpdateDetachedBeatmapSet() { RunTestWithRealmAsync(async(realm, storage) => { using (var importer = new BeatmapModelManager(realm, storage)) using (new RealmRulesetStore(realm, storage)) { Live <BeatmapSetInfo>?beatmapSet; using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream())) beatmapSet = await importer.Import(reader); Assert.NotNull(beatmapSet); Debug.Assert(beatmapSet != null); // Detach at the BeatmapInfo point, similar to what GetWorkingBeatmap does. BeatmapInfo?detachedBeatmap = null; beatmapSet.PerformRead(s => detachedBeatmap = s.Beatmaps.First().Detach()); BeatmapSetInfo?detachedBeatmapSet = detachedBeatmap?.BeatmapSet; Debug.Assert(detachedBeatmapSet != null); var newUser = new RealmUser { Username = "******", OnlineID = 2 }; detachedBeatmapSet.Beatmaps.First().Metadata.Artist = "New Artist"; detachedBeatmapSet.Beatmaps.First().Metadata.Author = newUser; Assert.AreNotEqual(detachedBeatmapSet.Status, BeatmapOnlineStatus.Ranked); detachedBeatmapSet.Status = BeatmapOnlineStatus.Ranked; beatmapSet.PerformWrite(s => { detachedBeatmapSet.CopyChangesToRealm(s); }); beatmapSet.PerformRead(s => { // Check above changes explicitly. Assert.AreEqual(BeatmapOnlineStatus.Ranked, s.Status); Assert.AreEqual("New Artist", s.Beatmaps.First().Metadata.Artist); Assert.AreEqual(newUser, s.Beatmaps.First().Metadata.Author); Assert.NotZero(s.Files.Count); // Check nothing was lost in the copy operation. Assert.AreEqual(s.Files.Count, detachedBeatmapSet.Files.Count); Assert.AreEqual(s.Files.Select(f => f.File).Count(), detachedBeatmapSet.Files.Select(f => f.File).Count()); Assert.AreEqual(s.Beatmaps.Count, detachedBeatmapSet.Beatmaps.Count); Assert.AreEqual(s.Beatmaps.Select(f => f.Difficulty).Count(), detachedBeatmapSet.Beatmaps.Select(f => f.Difficulty).Count()); Assert.AreEqual(s.Metadata, detachedBeatmapSet.Metadata); }); } }); }
private BeatmapInfo createTestBeatmap([NotNull] RealmUser author) { var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)).BeatmapInfo; beatmap.Metadata.Author = author; beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title"; beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist"; return(beatmap); }
public void TestExcessMods() { AddStep("show excess mods score", () => { var author = new RealmUser { Username = "******" }; var score = TestResources.CreateTestScoreInfo(createTestBeatmap(author)); score.Mods = score.BeatmapInfo.Ruleset.CreateInstance().CreateAllMods().ToArray(); showPanel(score); }); AddAssert("mapper name present", () => this.ChildrenOfType <OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name")); }
private void migrateScores(OsuDbContext db) { // can be removed 20220730. var existingScores = db.ScoreInfo .Include(s => s.Ruleset) .Include(s => s.BeatmapInfo) .Include(s => s.Files) .ThenInclude(f => f.FileInfo) .AsSplitQuery(); log("Beginning scores migration to realm"); // previous entries in EF are removed post migration. if (!existingScores.Any()) { log("No scores found to migrate"); return; } int count = existingScores.Count(); realm.Run(r => { log($"Found {count} scores in EF"); var transaction = r.BeginWrite(); int written = 0; int missing = 0; try { foreach (var score in existingScores) { if (++written % 1000 == 0) { transaction.Commit(); transaction = r.BeginWrite(); log($"Migrated {written}/{count} scores..."); } var beatmap = r.All <BeatmapInfo>().FirstOrDefault(b => b.Hash == score.BeatmapInfo.Hash); var ruleset = r.Find <RulesetInfo>(score.Ruleset.ShortName); if (beatmap == null || ruleset == null) { log($"Skipping {++missing} scores with missing ruleset or beatmap"); continue; } var user = new RealmUser { OnlineID = score.User.OnlineID, Username = score.User.Username }; var realmScore = new ScoreInfo(beatmap, ruleset, user) { Hash = score.Hash, DeletePending = score.DeletePending, OnlineID = score.OnlineID ?? -1, ModsJson = score.ModsJson, StatisticsJson = score.StatisticsJson, TotalScore = score.TotalScore, MaxCombo = score.MaxCombo, Accuracy = score.Accuracy, HasReplay = ((IScoreInfo)score).HasReplay, Date = score.Date, PP = score.PP, Rank = score.Rank, HitEvents = score.HitEvents, Passed = score.Passed, Combo = score.Combo, Position = score.Position, Statistics = score.Statistics, Mods = score.Mods, APIMods = score.APIMods, }; migrateFiles(score, r, realmScore); r.Add(realmScore); } } finally { transaction.Commit(); } log($"Successfully migrated {count} scores to realm"); }); }