mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09: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 class TestDummyAPIRequestHandling : OsuTestScene
|
||||||
{
|
{
|
||||||
public TestDummyAPIRequestHandling()
|
[Test]
|
||||||
|
public void TestGenericRequestHandling()
|
||||||
{
|
{
|
||||||
AddStep("register request handling", () => ((DummyAPIAccess)API).HandleRequest = req =>
|
AddStep("register request handling", () => ((DummyAPIAccess)API).HandleRequest = req =>
|
||||||
{
|
{
|
||||||
@ -33,7 +34,10 @@ namespace osu.Game.Tests.Online
|
|||||||
API.Queue(request);
|
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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.IO.Network;
|
using osu.Framework.IO.Network;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -98,10 +99,15 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
|
||||||
Success?.Invoke();
|
TriggerSuccess();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void TriggerSuccess()
|
||||||
|
{
|
||||||
|
Success?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
public void Cancel() => Fail(new OperationCanceledException(@"Request cancelled"));
|
||||||
|
|
||||||
public void Fail(Exception e)
|
public void Fail(Exception e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user