コード例 #1
0
ファイル: EoPromises.cs プロジェクト: sav/efl
        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);
        }
コード例 #2
0
ファイル: EoPromises.cs プロジェクト: sav/efl
        public static void test_object_promise()
        {
            efl.ILoop    loop = efl.App.GetLoopMain();
            test.Testing obj  = new test.Testing();

            eina.Future future = obj.GetFuture();

            bool callbackCalled = false;
            int  receivedValue  = -1;
            int  sentValue      = 1984;

            future.Then((eina.Value value) => {
                callbackCalled = true;
                Test.AssertEquals(value.GetValueType(), eina.ValueType.Int32);
                value.Get(out receivedValue);

                return(value);
            });

            obj.FulfillPromise(sentValue);

            loop.Iterate();
            Test.Assert(callbackCalled, "Future callback must have been called.");
            Test.AssertEquals(receivedValue, sentValue);
        }