From e3a9fbecfea26045e819fbeabb51ecb15d7ca343 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 1 Nov 2021 16:42:22 +0900 Subject: [PATCH] Add method to create sample `APIBeatmap` (with `BeatmapSet` populated) --- osu.Game/Tests/Visual/OsuTestScene.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/osu.Game/Tests/Visual/OsuTestScene.cs b/osu.Game/Tests/Visual/OsuTestScene.cs index 90e85f7716..090a085f71 100644 --- a/osu.Game/Tests/Visual/OsuTestScene.cs +++ b/osu.Game/Tests/Visual/OsuTestScene.cs @@ -175,6 +175,28 @@ namespace osu.Game.Tests.Visual protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); + /// + /// Returns a sample API Beatmap with BeatmapSet populated. + /// + /// The ruleset to create the sample model using. + protected APIBeatmap CreateAPIBeatmap(RulesetInfo ruleset) + { + var beatmapSet = CreateAPIBeatmapSet(ruleset); + + // Avoid circular reference. + var beatmap = beatmapSet.Beatmaps.First(); + beatmapSet.Beatmaps = Array.Empty(); + + // Populate the set as that's generally what we expect from the API. + beatmap.BeatmapSet = beatmapSet; + + return beatmap; + } + + /// + /// Returns a sample API BeatmapSet with beatmaps populated. + /// + /// The ruleset to create the sample model using. protected APIBeatmapSet CreateAPIBeatmapSet(RulesetInfo ruleset) { var beatmap = CreateBeatmap(ruleset).BeatmapInfo;