Example #1
0
    public void test_wait_for_specific_action()
    {
        var timer    = new Timer();
        var instance = new Actions(timer);
        var complete = false;
        var count    = 0;

        // Run an action which doesn't resolved immediately
        var task = new DeferredAction();

        instance.Execute(task, (ep) =>
        {
            count   += 1;
            complete = true;
        });
        Assert(complete == false);

        // Run some other action
        // Notice how all ActionCompleteEvents are skipped until the matching action.
        instance.Execute <SimpleAction>();
        instance.Execute <SimpleAction>();
        instance.Execute <SimpleAction>();
        Assert(count == 0);
        Assert(complete == false);

        // Now we fake the deferred completion, and correctly catch it
        task.Complete();
        Assert(count == 1);
        Assert(complete == true);
    }
    public void test_wait_for_specific_action()
    {
        var timer = new Timer();
        var instance = new Actions(timer);
        var complete = false;
        var count = 0;

        // Run an action which doesn't resolved immediately
        var task = new DeferredAction();
        instance.Execute(task, (ep) =>
        {
            count += 1;
            complete = true;
        });
        Assert(complete == false);

        // Run some other action
        // Notice how all ActionCompleteEvents are skipped until the matching action.
        instance.Execute<SimpleAction>();
        instance.Execute<SimpleAction>();
        instance.Execute<SimpleAction>();
        Assert(count == 0);
        Assert(complete == false);

        // Now we fake the deferred completion, and correctly catch it
        task.Complete();
        Assert(count == 1);
        Assert(complete == true);
    }