Ejemplo n.º 1
0
        public void InvokesOnResolvedWhenCompleted()
        {
            var    f1             = new Future <int>();
            var    f2             = new Future <int>();
            var    f3             = new Future <int>();
            object completeResult = null;
            var    handler        = (OnFutureResolved <int>)(
                (f) => {
                completeResult =
                    (f.Disposed)
                            ? "disposed"
                            : (f.Failed
                                ? f.Error
                                : (object)f.Result
                               );
            }
                );

            f1.RegisterOnResolved2(handler);
            f1.Complete(5);
            Assert.AreEqual(5, completeResult);
            f2.RegisterOnResolved2(handler);
            f2.Dispose();
            Assert.AreEqual("disposed", completeResult);
            f3.RegisterOnResolved2(handler);
            var exc = new Exception("test");

            f3.SetResult(0, exc);
            Assert.AreEqual(exc, completeResult);
        }