mirror of https://github.com/ppy/osu
Refactor test for readability
This commit is contained in:
parent
ac67320b61
commit
1d1b855510
|
@ -169,44 +169,26 @@ public void TestPickBanOrder()
|
||||||
AddStep("update displayed maps", () => Ladder.SplitMapPoolByMods.Value = false);
|
AddStep("update displayed maps", () => Ladder.SplitMapPoolByMods.Value = false);
|
||||||
|
|
||||||
AddStep("start bans from blue team", () => screen.ChildrenOfType<TourneyButton>().First(btn => btn.Text == "Blue Ban").TriggerClick());
|
AddStep("start bans from blue team", () => screen.ChildrenOfType<TourneyButton>().First(btn => btn.Text == "Blue Ban").TriggerClick());
|
||||||
|
|
||||||
AddStep("ban map", () => clickBeatmapPanel(0));
|
AddStep("ban map", () => clickBeatmapPanel(0));
|
||||||
AddAssert("one ban registered", () => Ladder.CurrentMatch.Value!.PicksBans, () => Has.Count.EqualTo(1));
|
checkTotalPickBans(1);
|
||||||
AddAssert("ban was blue's",
|
checkLastPick(ChoiceType.Ban, TeamColour.Blue);
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Count(pb => pb.Type == ChoiceType.Ban && pb.Team == TeamColour.Blue),
|
|
||||||
() => Is.EqualTo(1));
|
|
||||||
|
|
||||||
AddStep("ban map", () => clickBeatmapPanel(1));
|
AddStep("ban map", () => clickBeatmapPanel(1));
|
||||||
AddAssert("two bans registered", () => Ladder.CurrentMatch.Value!.PicksBans, () => Has.Count.EqualTo(2));
|
checkTotalPickBans(2);
|
||||||
AddAssert("one ban for red team",
|
checkLastPick(ChoiceType.Ban, TeamColour.Red);
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Count(pb => pb.Type == ChoiceType.Ban && pb.Team == TeamColour.Red),
|
|
||||||
() => Is.EqualTo(1));
|
|
||||||
AddAssert("one ban for blue team",
|
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Count(pb => pb.Type == ChoiceType.Ban && pb.Team == TeamColour.Blue),
|
|
||||||
() => Is.EqualTo(1));
|
|
||||||
|
|
||||||
AddStep("pick map", () => clickBeatmapPanel(2));
|
AddStep("pick map", () => clickBeatmapPanel(2));
|
||||||
AddAssert("one pick registered",
|
checkTotalPickBans(3);
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Count(pb => pb.Type == ChoiceType.Pick),
|
checkLastPick(ChoiceType.Pick, TeamColour.Red);
|
||||||
() => Is.EqualTo(1));
|
|
||||||
AddAssert("pick was red's",
|
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Last().Team,
|
|
||||||
() => Is.EqualTo(TeamColour.Red));
|
|
||||||
|
|
||||||
AddStep("pick map", () => clickBeatmapPanel(3));
|
AddStep("pick map", () => clickBeatmapPanel(3));
|
||||||
AddAssert("two picks registered",
|
checkTotalPickBans(4);
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Count(pb => pb.Type == ChoiceType.Pick),
|
checkLastPick(ChoiceType.Pick, TeamColour.Blue);
|
||||||
() => Is.EqualTo(2));
|
|
||||||
AddAssert("pick was blue's",
|
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Last().Team,
|
|
||||||
() => Is.EqualTo(TeamColour.Blue));
|
|
||||||
|
|
||||||
AddStep("pick map", () => clickBeatmapPanel(4));
|
AddStep("pick map", () => clickBeatmapPanel(4));
|
||||||
AddAssert("three picks registered",
|
checkTotalPickBans(5);
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Count(pb => pb.Type == ChoiceType.Pick),
|
checkLastPick(ChoiceType.Pick, TeamColour.Red);
|
||||||
() => Is.EqualTo(3));
|
|
||||||
AddAssert("pick was red's",
|
|
||||||
() => Ladder.CurrentMatch.Value!.PicksBans.Last().Team,
|
|
||||||
() => Is.EqualTo(TeamColour.Red));
|
|
||||||
|
|
||||||
AddStep("reset match", () =>
|
AddStep("reset match", () =>
|
||||||
{
|
{
|
||||||
|
@ -214,6 +196,13 @@ public void TestPickBanOrder()
|
||||||
Ladder.CurrentMatch.Value = Ladder.Matches.First();
|
Ladder.CurrentMatch.Value = Ladder.Matches.First();
|
||||||
Ladder.CurrentMatch.Value.PicksBans.Clear();
|
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]
|
[Test]
|
||||||
|
|
Loading…
Reference in New Issue