Пример #1
0
        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);
        }
Пример #2
0
        public static void test_async_fulfill()
        {
            efl.ILoop     loop = efl.App.GetLoopMain();
            test.ITesting obj  = new test.Testing();

            Task <eina.Value> task = obj.GetFutureAsync();

            int sentValue = 1337;

            obj.FulfillPromise(sentValue);
            loop.Iterate();

            eina.Value v = task.Result;
            Test.AssertEquals(v.GetValueType(), eina.ValueType.Int32);

            int receivedValue;

            v.Get(out receivedValue);
            Test.AssertEquals(receivedValue, sentValue);
        }