Last active
April 23, 2018 14:16
-
-
Save lauromoura/834c9de76dbd04609d27696c81689c10 to your computer and use it in GitHub Desktop.
Initial tests on eina promises support for efl C# bindings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TestSuite | |
{ | |
class TestPromises | |
{ | |
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."); | |
} | |
public static void test_simple_resolve() | |
{ | |
bool callbackCalled = false; | |
eina.Value received_value = null; | |
efl.Loop loop = efl.AppConcrete.GetLoopMain(); | |
eina.Promise promise = new eina.Promise(() => {}); | |
eina.Future future = new eina.Future(promise); | |
future = future.Then((eina.Value value) => { | |
callbackCalled = true; | |
received_value = value; | |
return value; | |
} ); | |
eina.Value reference_value = new eina.Value(eina.ValueType.Int32); | |
reference_value.Set(1984); | |
promise.Resolve(reference_value); | |
loop.Iterate(); | |
Test.Assert(callbackCalled, "Future callback should have been called."); | |
Test.AssertEquals(received_value, reference_value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment