From 49ca1ccb22792b973f49d409eec464de1ab75d74 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Dec 2023 12:03:54 +0900 Subject: [PATCH] Simplify state reset in test scene --- .../Screens/TestSceneMapPoolScreen.cs | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index 5e535e2749..7e008a6897 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -24,14 +24,24 @@ private void load() Add(screen = new TestMapPoolScreen { Width = 0.7f }); } - [SetUp] - public void SetUp() => Schedule(() => + [SetUpSteps] + public override void SetUpSteps() + { + AddStep("reset state", resetState); + } + + private void resetState() { Ladder.SplitMapPoolByMods.Value = true; Ladder.CurrentMatch.Value = new TournamentMatch(); Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value.PicksBans.Clear(); + } + + [SetUp] + public void SetUp() => Schedule(() => + { }); [Test] @@ -48,7 +58,6 @@ public void TestFewMaps() AddStep("reset match", () => { Ladder.CurrentMatch.Value = new TournamentMatch(); - Ladder.CurrentMatch.Value = Ladder.Matches.First(); }); assertTwoWide(); @@ -65,11 +74,7 @@ public void TestJustEnoughMaps() addBeatmap(); }); - AddStep("reset match", () => - { - Ladder.CurrentMatch.Value = new TournamentMatch(); - Ladder.CurrentMatch.Value = Ladder.Matches.First(); - }); + AddStep("reset state", resetState); assertTwoWide(); } @@ -85,11 +90,7 @@ public void TestManyMaps() addBeatmap(); }); - AddStep("reset match", () => - { - Ladder.CurrentMatch.Value = new TournamentMatch(); - Ladder.CurrentMatch.Value = Ladder.Matches.First(); - }); + AddStep("reset state", resetState); assertThreeWide(); } @@ -105,11 +106,7 @@ public void TestJustEnoughMods() addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); }); - AddStep("reset match", () => - { - Ladder.CurrentMatch.Value = new TournamentMatch(); - Ladder.CurrentMatch.Value = Ladder.Matches.First(); - }); + AddStep("reset state", resetState); assertTwoWide(); } @@ -131,11 +128,7 @@ public void TestManyMods() addBeatmap(i > 4 ? Ruleset.Value.CreateInstance().AllMods.ElementAt(i).Acronym : "NM"); }); - AddStep("reset match", () => - { - Ladder.CurrentMatch.Value = new TournamentMatch(); - Ladder.CurrentMatch.Value = Ladder.Matches.First(); - }); + AddStep("reset state", resetState); assertThreeWide(); } @@ -153,11 +146,7 @@ public void TestSplitMapPoolByMods() AddStep("disable splitting map pool by mods", () => Ladder.SplitMapPoolByMods.Value = false); - AddStep("reset match", () => - { - Ladder.CurrentMatch.Value = new TournamentMatch(); - Ladder.CurrentMatch.Value = Ladder.Matches.First(); - }); + AddStep("reset state", resetState); } [Test]