From 5477af08c5d972988df03b7834ff5ff0f039a9cf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 16 Feb 2022 17:21:06 +0900 Subject: [PATCH] Register an `AssemblyRulesetStore` in tests which don't use `OsuGameBase` --- osu.Game.Benchmarks/BenchmarkBeatmapParsing.cs | 3 +++ osu.Game.Rulesets.Osu.Tests/StackingTest.cs | 6 ++++++ .../Beatmaps/Formats/LegacyBeatmapDecoderTest.cs | 7 +++++++ osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs | 7 +++++++ osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs | 7 +++++++ osu.Game.Tests/Editing/LegacyEditorBeatmapPatcherTest.cs | 3 +++ osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs | 1 - osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs | 6 ++++++ osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs | 6 ++++++ 9 files changed, 45 insertions(+), 1 deletion(-) diff --git a/osu.Game.Benchmarks/BenchmarkBeatmapParsing.cs b/osu.Game.Benchmarks/BenchmarkBeatmapParsing.cs index 1d207d04c7..0dd66be0b4 100644 --- a/osu.Game.Benchmarks/BenchmarkBeatmapParsing.cs +++ b/osu.Game.Benchmarks/BenchmarkBeatmapParsing.cs @@ -8,6 +8,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; using osu.Game.IO; using osu.Game.IO.Archives; +using osu.Game.Rulesets; using osu.Game.Tests.Resources; namespace osu.Game.Benchmarks @@ -18,6 +19,8 @@ namespace osu.Game.Benchmarks public override void SetUp() { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + using (var resources = new DllResourceStore(typeof(TestResources).Assembly)) using (var archive = resources.GetStream("Resources/Archives/241526 Soleily - Renatus.osz")) using (var reader = new ZipArchiveReader(archive)) diff --git a/osu.Game.Rulesets.Osu.Tests/StackingTest.cs b/osu.Game.Rulesets.Osu.Tests/StackingTest.cs index 871afdb09d..927c0c3e1e 100644 --- a/osu.Game.Rulesets.Osu.Tests/StackingTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/StackingTest.cs @@ -18,6 +18,12 @@ namespace osu.Game.Rulesets.Osu.Tests [TestFixture] public class StackingTest { + [SetUp] + public void SetUp() + { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + } + [Test] public void TestStacking() { diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs index 468cb7683c..ad088d298b 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs @@ -11,6 +11,7 @@ using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Timing; using osu.Game.IO; +using osu.Game.Rulesets; using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Catch.Beatmaps; using osu.Game.Rulesets.Mods; @@ -29,6 +30,12 @@ namespace osu.Game.Tests.Beatmaps.Formats [TestFixture] public class LegacyBeatmapDecoderTest { + [SetUp] + public void SetUp() + { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + } + [Test] public void TestDecodeBeatmapVersion() { diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs index 2eb75259d9..b7989adcb8 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuJsonDecoderTest.cs @@ -10,6 +10,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; using osu.Game.IO; using osu.Game.IO.Serialization; +using osu.Game.Rulesets; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Beatmaps; @@ -22,6 +23,12 @@ namespace osu.Game.Tests.Beatmaps.Formats [TestFixture] public class OsuJsonDecoderTest { + [SetUp] + public void SetUp() + { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + } + private const string normal = "Soleily - Renatus (Gamu) [Insane].osu"; private const string marathon = "Within Temptation - The Unforgiving (Armin) [Marathon].osu"; private const string with_sb = "Kozato snow - Rengetsu Ouka (_Kiva) [Yuki YukI].osu"; diff --git a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs index 810ea5dbd0..64a52b2b01 100644 --- a/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/OszArchiveReaderTest.cs @@ -9,12 +9,19 @@ using osu.Game.Tests.Resources; using osu.Game.Beatmaps.Formats; using osu.Game.IO; using osu.Game.IO.Archives; +using osu.Game.Rulesets; namespace osu.Game.Tests.Beatmaps.IO { [TestFixture] public class OszArchiveReaderTest { + [SetUp] + public void SetUp() + { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + } + [Test] public void TestReadBeatmaps() { diff --git a/osu.Game.Tests/Editing/LegacyEditorBeatmapPatcherTest.cs b/osu.Game.Tests/Editing/LegacyEditorBeatmapPatcherTest.cs index 44a908b756..6cf760723a 100644 --- a/osu.Game.Tests/Editing/LegacyEditorBeatmapPatcherTest.cs +++ b/osu.Game.Tests/Editing/LegacyEditorBeatmapPatcherTest.cs @@ -8,6 +8,7 @@ using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Formats; using osu.Game.IO; +using osu.Game.Rulesets; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu; @@ -28,6 +29,8 @@ namespace osu.Game.Tests.Editing [SetUp] public void Setup() { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + patcher = new LegacyEditorBeatmapPatcher(current = new EditorBeatmap(new OsuBeatmap { BeatmapInfo = diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index fb7882c182..9626f39ec3 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Data; using System.IO; using System.Linq; using osu.Framework.Extensions; diff --git a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs index 8d622955b7..d5b7e3152b 100644 --- a/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs +++ b/osu.Game/Tests/Beatmaps/BeatmapConversionTest.cs @@ -34,6 +34,12 @@ namespace osu.Game.Tests.Beatmaps protected abstract string ResourceAssembly { get; } + [SetUp] + public void Setup() + { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + } + protected void Test(string name, params Type[] mods) { var ourResult = convert(name, mods.Select(m => (Mod)Activator.CreateInstance(m)).ToArray()); diff --git a/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs b/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs index 9f8811c7f9..78b2558640 100644 --- a/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs +++ b/osu.Game/Tests/Beatmaps/DifficultyCalculatorTest.cs @@ -22,6 +22,12 @@ namespace osu.Game.Tests.Beatmaps protected abstract string ResourceAssembly { get; } + [SetUp] + public void Setup() + { + Decoder.RegisterDependencies(new AssemblyRulesetStore()); + } + protected void Test(double expected, string name, params Mod[] mods) { // Platform-dependent math functions (Pow, Cbrt, Exp, etc) may result in minute differences.