From 73aaa0406a35786e07ac8c11b07e018522303d85 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Dec 2023 12:00:32 +0900 Subject: [PATCH] Add test coverage of multiple bans order --- .../Screens/TestSceneMapPoolScreen.cs | 61 ++++++++++++++++--- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs index dcf9dc47b9..5e535e2749 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneMapPoolScreen.cs @@ -25,7 +25,14 @@ namespace osu.Game.Tournament.Tests.Screens } [SetUp] - public void SetUp() => Schedule(() => Ladder.SplitMapPoolByMods.Value = true); + public void SetUp() => Schedule(() => + { + Ladder.SplitMapPoolByMods.Value = true; + + Ladder.CurrentMatch.Value = new TournamentMatch(); + Ladder.CurrentMatch.Value = Ladder.Matches.First(); + Ladder.CurrentMatch.Value.PicksBans.Clear(); + }); [Test] public void TestFewMaps() @@ -153,6 +160,44 @@ namespace osu.Game.Tournament.Tests.Screens }); } + [Test] + public void TestBanOrderMultipleBans() + { + AddStep("set ban count", () => Ladder.CurrentMatch.Value!.Round.Value!.BanCount.Value = 2); + + AddStep("load some maps", () => + { + Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Clear(); + + for (int i = 0; i < 5; i++) + addBeatmap(); + }); + + AddStep("update displayed maps", () => Ladder.SplitMapPoolByMods.Value = false); + + AddStep("start bans from blue team", () => screen.ChildrenOfType().First(btn => btn.Text == "Blue Ban").TriggerClick()); + + AddStep("ban map", () => clickBeatmapPanel(0)); + checkTotalPickBans(1); + checkLastPick(ChoiceType.Ban, TeamColour.Blue); + + AddStep("ban map", () => clickBeatmapPanel(1)); + checkTotalPickBans(2); + checkLastPick(ChoiceType.Ban, TeamColour.Red); + + AddStep("ban map", () => clickBeatmapPanel(2)); + checkTotalPickBans(3); + checkLastPick(ChoiceType.Ban, TeamColour.Red); + + AddStep("pick map", () => clickBeatmapPanel(3)); + checkTotalPickBans(4); + checkLastPick(ChoiceType.Ban, TeamColour.Blue); + + AddStep("pick map", () => clickBeatmapPanel(4)); + checkTotalPickBans(5); + checkLastPick(ChoiceType.Pick, TeamColour.Blue); + } + [Test] public void TestPickBanOrder() { @@ -196,13 +241,6 @@ namespace osu.Game.Tournament.Tests.Screens Ladder.CurrentMatch.Value = Ladder.Matches.First(); Ladder.CurrentMatch.Value.PicksBans.Clear(); }); - - void checkTotalPickBans(int expected) => AddAssert($"total pickbans is {expected}", () => Ladder.CurrentMatch.Value!.PicksBans, () => Has.Count.EqualTo(expected)); - - void checkLastPick(ChoiceType expectedChoice, TeamColour expectedColour) => - AddAssert($"last choice was {expectedChoice} by {expectedColour}", - () => Ladder.CurrentMatch.Value!.PicksBans.Select(pb => (pb.Type, pb.Team)).Last(), - () => Is.EqualTo((expectedChoice, expectedColour))); } [Test] @@ -296,6 +334,13 @@ namespace osu.Game.Tournament.Tests.Screens }); } + private void checkTotalPickBans(int expected) => AddAssert($"total pickbans is {expected}", () => Ladder.CurrentMatch.Value!.PicksBans, () => Has.Count.EqualTo(expected)); + + private void checkLastPick(ChoiceType expectedChoice, TeamColour expectedColour) => + AddAssert($"last choice was {expectedChoice} by {expectedColour}", + () => Ladder.CurrentMatch.Value!.PicksBans.Select(pb => (pb.Type, pb.Team)).Last(), + () => Is.EqualTo((expectedChoice, expectedColour))); + private void addBeatmap(string mods = "NM") { Ladder.CurrentMatch.Value!.Round.Value!.Beatmaps.Add(new RoundBeatmap