From ce47b7ca932f85b2ac323b0c220da2eaa88dd3ef Mon Sep 17 00:00:00 2001 From: Endrik Tombak Date: Sat, 25 Apr 2020 10:21:01 +0300 Subject: [PATCH] Unnest in SetUpSteps --- .../TestSceneBeatmapRecommendations.cs | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs index ec5fe65fdd..3f2117a4f8 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapRecommendations.cs @@ -36,31 +36,48 @@ namespace osu.Game.Tests.Visual.SongSelect switch (req) { case GetUserRequest userRequest: - - decimal pp = userRequest.Ruleset.ID switch - { - 0 => 336, // Expected recommended star difficulty 2* - 1 => 928, // Expected recommended star difficulty 3* - 2 => 1905, // Expected recommended star difficulty 4* - 3 => 3329, // Expected recommended star difficulty 5* - _ => 0 - }; - - userRequest.TriggerSuccess(new User - { - Username = @"Dummy", - Id = 1001, - Statistics = new UserStatistics - { - PP = pp - } - }); + userRequest.TriggerSuccess(getUser(userRequest.Ruleset.ID)); break; } }; - // Force recommender to calculate its star ratings again - recommender.APIStateChanged(API, APIState.Online); }); + + // Force recommender to calculate its star ratings again + AddStep("calculate recommended SRs", () => recommender.APIStateChanged(API, APIState.Online)); + + User getUser(int? rulesetID) + { + return new User + { + Username = @"Dummy", + Id = 1001, + Statistics = new UserStatistics + { + PP = getNecessaryPP(rulesetID) + } + }; + } + + decimal getNecessaryPP(int? rulesetID) + { + switch (rulesetID) + { + case 0: + return 336; + + case 1: + return 928; + + case 2: + return 1905; + + case 3: + return 3329; + + default: + return 0; + } + } } [Test]