예제 #1
0
        public static void test_simple_cancel()
        {
            bool cleanCalled = false;

            Eina.Promise promise = new Eina.Promise(() => { cleanCalled = true; });
            Eina.Future  future  = new Eina.Future(promise);
            future.Cancel();
            Test.Assert(cleanCalled, "Promise clean callback should have been called.");
            Test.AssertRaises <ObjectDisposedException>(() => { promise.Resolve(null); });
            Test.AssertRaises <ObjectDisposedException>(future.Cancel);
        }
예제 #2
0
        public static void test_simple_future_cancel()
        {
            bool callbackCalled        = false;
            bool promiseCallbackCalled = false;

            Eina.Error received_error = Eina.Error.NO_ERROR;

            Eina.Promise promise = new Eina.Promise(() => { promiseCallbackCalled = true; });
            Eina.Future  future  = new Eina.Future(promise);

            future = future.Then((Eina.Value value) => {
                callbackCalled = true;
                value.Get(out received_error);
                return(value);
            });

            future.Cancel();

            Test.Assert(promiseCallbackCalled, "Promise cancel callback should have been called.");
            Test.Assert(callbackCalled, "Future callback should have been called.");
            Test.AssertEquals(received_error, Eina.Error.ECANCELED);
        }