From b36c406a83b35721e72c37ecd3447f0ba5541daf Mon Sep 17 00:00:00 2001 From: Gagah Pangeran Rosfatiputra Date: Thu, 3 Jun 2021 19:48:04 +0700 Subject: [PATCH] add test scene for error page --- .../Visual/Online/TestSceneWikiOverlay.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs index da4bf82948..4d09ed21dc 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneWikiOverlay.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Net; using NUnit.Framework; using osu.Game.Online.API; using osu.Game.Online.API.Requests; @@ -32,7 +33,14 @@ public void TestArticlePage() AddStep("Show Article Page", () => wiki.ShowPage("Interface")); } - private void setUpWikiResponse(APIWikiPage r) + [Test] + public void TestErrorPage() + { + setUpWikiResponse(null, true); + AddStep("Show Error Page", () => wiki.ShowPage("Error")); + } + + private void setUpWikiResponse(APIWikiPage r, bool isFailed = false) => AddStep("set up response", () => { dummyAPI.HandleRequest = request => @@ -40,7 +48,11 @@ private void setUpWikiResponse(APIWikiPage r) if (!(request is GetWikiRequest getWikiRequest)) return false; - getWikiRequest.TriggerSuccess(r); + if (isFailed) + getWikiRequest.TriggerFailure(new WebException()); + else + getWikiRequest.TriggerSuccess(r); + return true; }; });