mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Fix remaining cases of incorrect GameplayState
construction in tests
Manual attempts to initialise replaced by a new `TestGameplayState` helper for ease of use.
This commit is contained in:
32
osu.Game/Tests/Gameplay/TestGameplayState.cs
Normal file
32
osu.Game/Tests/Gameplay/TestGameplayState.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
/// <summary>
|
||||
/// Static class providing a <see cref="Create"/> convenience method to retrieve a correctly-initialised <see cref="GameplayState"/> instance in testing scenarios.
|
||||
/// </summary>
|
||||
public static class TestGameplayState
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a correctly-initialised <see cref="GameplayState"/> instance for use in testing.
|
||||
/// </summary>
|
||||
public static GameplayState Create(Ruleset ruleset, IReadOnlyList<Mod>? mods = null, Score? score = null)
|
||||
{
|
||||
var beatmap = new TestBeatmap(ruleset.RulesetInfo);
|
||||
var workingBeatmap = new TestWorkingBeatmap(beatmap);
|
||||
var playableBeatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);
|
||||
|
||||
return new GameplayState(playableBeatmap, ruleset, mods, score);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user