Add test implementation of the ruleset config cache

This commit is contained in:
Bartłomiej Dach
2021-12-23 19:18:26 +01:00
parent 5cbaa028eb
commit 77da1e12d5
2 changed files with 27 additions and 0 deletions

View File

@ -31,6 +31,7 @@ using osu.Game.Rulesets.UI;
using osu.Game.Screens;
using osu.Game.Storyboards;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Rulesets;
namespace osu.Game.Tests.Visual
{
@ -119,6 +120,13 @@ namespace osu.Game.Tests.Visual
var baseDependencies = base.CreateChildDependencies(parent);
// to isolate ruleset configs in tests from the actual database and avoid state pollution problems,
// as well as problems due to the implementation details of the "real" implementation (the configs only being available at `LoadComplete()`),
// cache a test implementation of the ruleset config cache over the "real" one.
var isolatedBaseDependencies = new DependencyContainer(baseDependencies);
isolatedBaseDependencies.CacheAs<IRulesetConfigCache>(new TestRulesetConfigCache());
baseDependencies = isolatedBaseDependencies;
var providedRuleset = CreateRuleset();
if (providedRuleset != null)
baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(providedRuleset, baseDependencies);