예제 #1
0
파일: EoPromises.cs 프로젝트: zmike/efl-tmp
        public static void test_object_promise()
        {
            Efl.Loop loop = Efl.App.AppMain;
            var      obj  = new Dummy.TestObject();

            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
파일: EoPromises.cs 프로젝트: zmike/efl-tmp
        public static void test_async_fulfill()
        {
            Efl.Loop loop = Efl.App.AppMain;
            var      obj  = new Dummy.TestObject();

            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);
        }