mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 22:37:21 +08:00
Add support for Result fetching
This commit is contained in:
parent
832822858c
commit
415adecdf6
@ -10,7 +10,8 @@ namespace osu.Game.Tests.Online
|
||||
{
|
||||
public class TestDummyAPIRequestHandling : OsuTestScene
|
||||
{
|
||||
public TestDummyAPIRequestHandling()
|
||||
[Test]
|
||||
public void TestGenericRequestHandling()
|
||||
{
|
||||
AddStep("register request handling", () => ((DummyAPIAccess)API).HandleRequest = req =>
|
||||
{
|
||||
@ -33,7 +34,10 @@ namespace osu.Game.Tests.Online
|
||||
API.Queue(request);
|
||||
});
|
||||
|
||||
AddAssert("got response", () => response != null);
|
||||
AddAssert("response event fired", () => response != null);
|
||||
|
||||
AddAssert("request has response", () => request.Result == response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Framework.Logging;
|
||||
@ -98,10 +99,15 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
if (cancelled) return;
|
||||
|
||||
Success?.Invoke();
|
||||
TriggerSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
internal void TriggerSuccess()
|
||||
{
|
||||
Success?.Invoke();
|
||||
}
|
||||
|
||||
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
||||
|
||||
public void Fail(Exception e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user