mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add test implementation of the ruleset config cache
This commit is contained in:
19
osu.Game/Tests/Rulesets/TestRulesetConfigCache.cs
Normal file
19
osu.Game/Tests/Rulesets/TestRulesetConfigCache.cs
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Configuration;
|
||||
|
||||
namespace osu.Game.Tests.Rulesets
|
||||
{
|
||||
/// <summary>
|
||||
/// Test implementation of a <see cref="IRulesetConfigCache"/>, which ensures isolation between test scenes.
|
||||
/// </summary>
|
||||
public class TestRulesetConfigCache : IRulesetConfigCache
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, IRulesetConfigManager> configCache = new ConcurrentDictionary<string, IRulesetConfigManager>();
|
||||
|
||||
public IRulesetConfigManager GetConfigFor(Ruleset ruleset) => configCache.GetOrAdd(ruleset.ShortName, _ => ruleset.CreateConfig(null));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user