From a5a025de6867edbfb70cf13df58353da4ea044cc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jun 2019 10:26:35 +0900 Subject: [PATCH] Add proper tests --- .../Visual/Online/TestSceneShowMoreButton.cs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs index 936842bdfa..bccb263600 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneShowMoreButton.cs @@ -17,16 +17,39 @@ public class TestSceneShowMoreButton : OsuTestScene public TestSceneShowMoreButton() { - ShowMoreButton button; + ShowMoreButton button = null; + + int fireCount = 0; Add(button = new ShowMoreButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, - Action = () => { } + Action = () => + { + fireCount++; + // ReSharper disable once AccessToModifiedClosure + // ReSharper disable once PossibleNullReferenceException + Scheduler.AddDelayed(() => button.IsLoading = false, 2000); + } }); - AddStep("switch loading state", () => button.IsLoading = !button.IsLoading); + AddStep("click button", () => button.Click()); + + AddAssert("action fired once", () => fireCount == 1); + AddAssert("is in loading state", () => button.IsLoading); + + AddStep("click button", () => button.Click()); + + AddAssert("action not fired", () => fireCount == 1); + AddAssert("is in loading state", () => button.IsLoading); + + AddUntilStep("wait for loaded", () => !button.IsLoading); + + AddStep("click button", () => button.Click()); + + AddAssert("action fired twice", () => fireCount == 2); + AddAssert("is in loading state", () => button.IsLoading); } } }