public static void test_object_promise_cancel() { efl.ILoop loop = efl.App.GetLoopMain(); test.Testing obj = new test.Testing(); eina.Future future = obj.GetFuture(); bool callbackCalled = false; eina.Error receivedError = -1; eina.Error sentError = 120; future.Then((eina.Value value) => { callbackCalled = true; Test.AssertEquals(value.GetValueType(), eina.ValueType.Error); value.Get(out receivedError); return(value); }); obj.RejectPromise(sentError); loop.Iterate(); Test.Assert(callbackCalled, "Future callback must have been called."); Test.AssertEquals(receivedError, sentError); }
public static void test_async_reject() { efl.ILoop loop = efl.App.GetLoopMain(); test.ITesting obj = new test.Testing(); Task <eina.Value> task = obj.GetFutureAsync(); eina.Error sentError = 1337; obj.RejectPromise(sentError); loop.Iterate(); bool raised = false; try { eina.Value v = task.Result; } catch (AggregateException ae) { raised = true; ae.Handle((x) => { Test.Assert(x is efl.FutureException, "AggregateException must have been TaskCanceledException"); efl.FutureException ex = x as efl.FutureException; Test.AssertEquals(ex.Error, sentError); return(true); }); } Test.Assert(raised, "AggregateException must have been raised."); }