Пример #1
0
        public void OnContinueIsInvokedWhenPromiseIsCanceled()
        {
            CancelationSource cancelationSource1 = CancelationSource.New();
            var deferred = Promise.NewDeferred(cancelationSource1.Token);
            CancelationSource cancelationSource2 = CancelationSource.New();
            var deferred2 = Promise.NewDeferred(cancelationSource2.Token);

            int voidFinallyFired = 0;
            int intFinallyFired  = 0;

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => ++ voidFinallyFired
                                                          );
            TestHelper.AddContinueCallbacks <int, string>(deferred2.Promise,
                                                          onContinue: r => ++ intFinallyFired
                                                          );

            cancelationSource1.Cancel();
            cancelationSource2.Cancel("Cancel");

            Promise.Manager.HandleCompletes();
            Assert.AreEqual(TestHelper.continueVoidCallbacks * 2, voidFinallyFired);
            Assert.AreEqual(TestHelper.continueTCallbacks * 2, intFinallyFired);

            cancelationSource1.Dispose();
            cancelationSource2.Dispose();
            TestHelper.Cleanup();
        }
Пример #2
0
        public void OnContinueResultWhenPromiseIsResolved()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            int expected = 50;

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => Assert.AreEqual(r.State, Promise.State.Resolved)
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Resolved);
                Assert.AreEqual(expected, r.Result);
            }
                                                               );

            deferred.Resolve();
            deferredInt.Resolve(expected);

            Promise.Manager.HandleCompletes();

            TestHelper.Cleanup();
        }
Пример #3
0
        public void OnContinueCancelReasonWhenPromiseIsCanceled1()
        {
            CancelationSource cancelationSource1 = CancelationSource.New();
            var deferred = Promise.NewDeferred(cancelationSource1.Token);
            CancelationSource cancelationSource2 = CancelationSource.New();
            var deferredInt = Promise.NewDeferred <int>(cancelationSource2.Token);

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Canceled);
                Assert.AreEqual(null, r.CancelContainer.ValueType);
            }
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Canceled);
                Assert.AreEqual(null, r.CancelContainer.ValueType);
            }
                                                               );

            cancelationSource1.Cancel();
            cancelationSource2.Cancel();

            Promise.Manager.HandleCompletes();

            cancelationSource1.Dispose();
            cancelationSource2.Dispose();
            TestHelper.Cleanup();
        }
Пример #4
0
        public void OnContinueRejectReasonWhenPromiseIsRejected()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            string rejection = "Reject";

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Rejected);
                Assert.AreEqual(rejection, r.RejectContainer.Value);
            }
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Rejected);
                Assert.AreEqual(rejection, r.RejectContainer.Value);
            }
                                                               );

            deferred.Reject(rejection);
            deferredInt.Reject(rejection);

            Promise.Manager.HandleCompletes();

            TestHelper.Cleanup();
        }
        public void OnContinueWillBeInvokedWithCapturedValue1()
        {
            var deferred = Promise.NewDeferred();

            string expected = "expected";
            bool   invoked  = false;

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          captureValue: expected,
                                                          onContinueCapture: (cv, r) =>
            {
                Assert.AreEqual(expected, cv);
                invoked = true;
            }
                                                          );

            deferred.Reject("Reject");
            Promise.Manager.HandleCompletes();

            Assert.AreEqual(true, invoked);

            // Clean up.
            GC.Collect();
            Promise.Manager.HandleCompletesAndProgress();
            LogAssert.NoUnexpectedReceived();
        }
Пример #6
0
        public void OnContinueIsInvokedWhenPromiseIsRejected()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            int voidFinallyFired = 0;
            int intFinallyFired  = 0;

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => ++ voidFinallyFired
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r => ++ intFinallyFired
                                                               );
            deferred.Promise.Catch(() => { });
            deferredInt.Promise.Catch(() => { });

            deferred.Reject("Reject");
            deferredInt.Reject("Reject");


            Promise.Manager.HandleCompletes();
            Assert.AreEqual(TestHelper.continueVoidCallbacks * 2, voidFinallyFired);
            Assert.AreEqual(TestHelper.continueTCallbacks * 2, intFinallyFired);

            TestHelper.Cleanup();
        }
        public void OnContinueIsInvokedWhenPromiseIsResolved()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            int voidFinallyFired = 0;
            int intFinallyFired  = 0;

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => ++ voidFinallyFired
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r => ++ intFinallyFired
                                                               );

            deferred.Resolve();
            deferredInt.Resolve(50);

            Promise.Manager.HandleCompletes();
            Assert.AreEqual(TestHelper.continueVoidCallbacks, voidFinallyFired);
            Assert.AreEqual(TestHelper.continueTCallbacks, intFinallyFired);

            // Clean up.
            GC.Collect();
            Promise.Manager.HandleCompletesAndProgress();
            LogAssert.NoUnexpectedReceived();
        }
        public void OnContinueCancelReasonWhenPromiseIsCanceled1()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Canceled);
                Assert.AreEqual(null, r.CancelContainer.ValueType);
            }
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r =>
            {
                Assert.AreEqual(r.State, Promise.State.Canceled);
                Assert.AreEqual(null, r.CancelContainer.ValueType);
            }
                                                               );

            deferred.Cancel();
            deferredInt.Cancel();

            Promise.Manager.HandleCompletes();

            // Clean up.
            GC.Collect();
            Promise.Manager.HandleCompletesAndProgress();
            LogAssert.NoUnexpectedReceived();
        }
Пример #9
0
        public void OnContinueRethrowCancelReasonWhenPromiseIsCanceled0()
        {
            CancelationSource cancelationSource1 = CancelationSource.New();
            var deferred = Promise.NewDeferred(cancelationSource1.Token);
            CancelationSource cancelationSource2 = CancelationSource.New();
            var deferredInt = Promise.NewDeferred <int>(cancelationSource2.Token);

            int    cancelations = 0;
            string cancelation  = "Cancel";

            Promise.ResultContainer        voidContainer = default(Promise.ResultContainer);
            Promise <int> .ResultContainer intContainer  = default(Promise <int> .ResultContainer);

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => voidContainer = r,
                                                          promiseToVoid: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); },
                                                          promiseToConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); return(0); },
                                                          promiseToPromise: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); return(null); },
                                                          promiseToPromiseConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); return(null); }
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r => intContainer = r,
                                                               promiseToVoid: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); },
                                                               promiseToConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); return(0); },
                                                               promiseToPromise: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); return(null); },
                                                               promiseToPromiseConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); return(null); }
                                                               );

            cancelationSource1.Cancel(cancelation);
            cancelationSource2.Cancel(cancelation);

            Promise.Manager.HandleCompletes();

            Assert.AreEqual(
                (TestHelper.continueVoidCallbacks + TestHelper.continueTCallbacks) * 2,
                cancelations
                );

            cancelationSource1.Dispose();
            cancelationSource2.Dispose();
            TestHelper.Cleanup();
        }
        public void OnContinueRethrowCancelReasonWhenPromiseIsCanceled0()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            int    cancelations = 0;
            string cancelation  = "Cancel";

            Promise.ResultContainer        voidContainer = default(Promise.ResultContainer);
            Promise <int> .ResultContainer intContainer  = default(Promise <int> .ResultContainer);

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => voidContainer = r,
                                                          promiseToVoid: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); },
                                                          promiseToConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); return(0); },
                                                          promiseToPromise: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); return(null); },
                                                          promiseToPromiseConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); voidContainer.RethrowIfCanceled(); return(null); }
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r => intContainer = r,
                                                               promiseToVoid: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); },
                                                               promiseToConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); return(0); },
                                                               promiseToPromise: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); return(null); },
                                                               promiseToPromiseConvert: p => { p.CatchCancelation(e => { Assert.AreEqual(cancelation, e.Value); ++cancelations; }); intContainer.RethrowIfCanceled(); return(null); }
                                                               );

            deferred.Cancel(cancelation);
            deferredInt.Cancel(cancelation);

            Promise.Manager.HandleCompletes();

            Assert.AreEqual(TestHelper.continueVoidCallbacks + TestHelper.continueTCallbacks,
                            cancelations);

            // Clean up.
            GC.Collect();
            Promise.Manager.HandleCompletesAndProgress();
            LogAssert.NoUnexpectedReceived();
        }
Пример #11
0
        public void OnContinueRethrowRejectReasonWhenPromiseIsRejected()
        {
            var deferred    = Promise.NewDeferred();
            var deferredInt = Promise.NewDeferred <int>();

            int    rejections = 0;
            string rejection  = "Reject";

            Promise.ResultContainer        voidContainer = default(Promise.ResultContainer);
            Promise <int> .ResultContainer intContainer  = default(Promise <int> .ResultContainer);

            TestHelper.AddContinueCallbacks <int, string>(deferred.Promise,
                                                          onContinue: r => voidContainer = r,
                                                          promiseToVoid: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); voidContainer.RethrowIfRejected(); },
                                                          promiseToConvert: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); voidContainer.RethrowIfRejected(); return(0); },
                                                          promiseToPromise: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); voidContainer.RethrowIfRejected(); return(null); },
                                                          promiseToPromiseConvert: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); voidContainer.RethrowIfRejected(); return(null); }
                                                          );
            TestHelper.AddContinueCallbacks <int, int, string>(deferredInt.Promise,
                                                               onContinue: r => intContainer = r,
                                                               promiseToVoid: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); intContainer.RethrowIfRejected(); },
                                                               promiseToConvert: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); intContainer.RethrowIfRejected(); return(0); },
                                                               promiseToPromise: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); intContainer.RethrowIfRejected(); return(null); },
                                                               promiseToPromiseConvert: p => { p.Catch((object e) => { Assert.AreEqual(rejection, e); ++rejections; }); intContainer.RethrowIfRejected(); return(null); }
                                                               );

            deferred.Reject(rejection);
            deferredInt.Reject(rejection);

            Promise.Manager.HandleCompletes();

            Assert.AreEqual(
                (TestHelper.continueVoidCallbacks + TestHelper.continueTCallbacks) * 2,
                rejections
                );

            TestHelper.Cleanup();
        }
Пример #12
0
        public void OnContinueWillBeInvokedWithCapturedValue2()
        {
            var deferred = Promise.NewDeferred <int>();

            string expected = "expected";
            bool   invoked  = false;

            TestHelper.AddContinueCallbacks <int, int, string>(deferred.Promise,
                                                               captureValue: expected,
                                                               onContinueCapture: (cv, r) =>
            {
                Assert.AreEqual(expected, cv);
                invoked = true;
            }
                                                               );

            deferred.Resolve(50);
            Promise.Manager.HandleCompletes();

            Assert.AreEqual(true, invoked);

            TestHelper.Cleanup();
        }
Пример #13
0
        public void AccessingRethrowInOnResolvedThrows()
        {
            var promise1 = Promise.Resolved();
            var promise2 = Promise.Resolved(100);

            int voidErrors = 0;
            int intErrors  = 0;

            Action <Promise> callback = p =>
            {
                p.Catch((object e) =>
                {
                    Assert.IsInstanceOf(typeof(InvalidOperationException), e);
                    ++voidErrors;
                });
                var _ = Promise.Rethrow;
            };
            Action <Promise> callbackT = p =>
            {
                p.Catch((object e) =>
                {
                    Assert.IsInstanceOf(typeof(InvalidOperationException), e);
                    ++intErrors;
                });
                var _ = Promise.Rethrow;
            };

            TestHelper.AddResolveCallbacks <int, string>(promise1,
                                                         promiseToVoid: callback,
                                                         promiseToConvert: p => { callback(p); return(0); },
                                                         promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                         promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                         );
            TestHelper.AddCallbacks <int, object, string>(promise1,
                                                          promiseToVoid: callback,
                                                          promiseToConvert: p => { callback(p); return(0); },
                                                          promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                          promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                          );
            TestHelper.AddContinueCallbacks <int, string>(promise1,
                                                          promiseToVoid: callback,
                                                          promiseToConvert: p => { callback(p); return(0); },
                                                          promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                          promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                          );

            TestHelper.AddResolveCallbacks <int, string>(promise2,
                                                         promiseToVoid: callbackT,
                                                         promiseToConvert: p => { callbackT(p); return(0); },
                                                         promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                         promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(0)); }
                                                         );
            TestHelper.AddCallbacks <int, bool, object, string>(promise2,
                                                                promiseToVoid: callbackT,
                                                                promiseToConvert: p => { callbackT(p); return(false); },
                                                                promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                                promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(false)); }
                                                                );
            TestHelper.AddContinueCallbacks <int, int, string>(promise2,
                                                               promiseToVoid: callbackT,
                                                               promiseToConvert: p => { callbackT(p); return(0); },
                                                               promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                               promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(0)); }
                                                               );

            Promise.Manager.HandleCompletes();

            Assert.AreEqual(TestHelper.resolveVoidVoidCallbacks + TestHelper.resolveVoidConvertCallbacks +
                            TestHelper.resolveVoidPromiseVoidCallbacks + TestHelper.resolveVoidPromiseConvertCallbacks +
                            TestHelper.continueVoidVoidCallbacks + TestHelper.continueVoidConvertCallbacks +
                            TestHelper.continueVoidPromiseVoidCallbacks + TestHelper.continueVoidPromiseConvertCallbacks,
                            voidErrors);
            Assert.AreEqual(TestHelper.resolveTVoidCallbacks + TestHelper.resolveTConvertCallbacks +
                            TestHelper.resolveTPromiseVoidCallbacks + TestHelper.resolveTPromiseConvertCallbacks +
                            TestHelper.continueTVoidCallbacks + TestHelper.continueTConvertCallbacks +
                            TestHelper.continueTPromiseVoidCallbacks + TestHelper.continueTPromiseConvertCallbacks,
                            intErrors);

            // Clean up.
            GC.Collect();
            Promise.Manager.HandleCompletesAndProgress();
            LogAssert.NoUnexpectedReceived();
        }
Пример #14
0
        public void ThrowingCancelExceptionInOnRejectedCancelsThePromiseWithTheGivenValue()
        {
            var promise1 = Promise.Rejected("Rejected");
            var promise2 = Promise.Rejected <int, string>("Rejected");

            int    voidCancelations = 0;
            int    intCancelations  = 0;
            string expected         = "Cancel!";

            Action <Promise> callback = p =>
            {
                p.CatchCancelation(reason =>
                {
                    Assert.AreEqual(expected, reason.Value);
                    ++voidCancelations;
                });
                throw Promise.CancelException(expected);
            };
            Action <Promise> callbackT = p =>
            {
                p.CatchCancelation(reason =>
                {
                    Assert.AreEqual(expected, reason.Value);
                    ++intCancelations;
                });
                throw Promise.CancelException(expected);
            };

            TestHelper.AddCallbacks <int, object, string>(promise1,
                                                          promiseToVoid: callback,
                                                          promiseToConvert: p => { callback(p); return(0); },
                                                          promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                          promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                          );
            TestHelper.AddContinueCallbacks <int, string>(promise1,
                                                          promiseToVoid: callback,
                                                          promiseToConvert: p => { callback(p); return(0); },
                                                          promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                          promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                          );

            TestHelper.AddCallbacks <int, bool, object, string>(promise2,
                                                                promiseToVoid: callbackT,
                                                                promiseToConvert: p => { callbackT(p); return(false); },
                                                                promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                                promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(false)); }
                                                                );
            TestHelper.AddContinueCallbacks <int, int, string>(promise2,
                                                               promiseToVoid: callbackT,
                                                               promiseToConvert: p => { callbackT(p); return(0); },
                                                               promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                               promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(0)); }
                                                               );

            Promise.Manager.HandleCompletes();

            Assert.AreEqual(TestHelper.rejectVoidVoidCallbacks + TestHelper.rejectVoidConvertCallbacks +
                            TestHelper.rejectVoidPromiseVoidCallbacks + TestHelper.rejectVoidPromiseConvertCallbacks +
                            TestHelper.continueVoidVoidCallbacks + TestHelper.continueVoidConvertCallbacks +
                            TestHelper.continueVoidPromiseVoidCallbacks + TestHelper.continueVoidPromiseConvertCallbacks,
                            voidCancelations);
            Assert.AreEqual(TestHelper.rejectTVoidCallbacks + TestHelper.rejectTConvertCallbacks +
                            TestHelper.rejectTPromiseVoidCallbacks + TestHelper.rejectTPromiseConvertCallbacks +
                            TestHelper.continueTVoidCallbacks + TestHelper.continueTConvertCallbacks +
                            TestHelper.continueTPromiseVoidCallbacks + TestHelper.continueTPromiseConvertCallbacks,
                            intCancelations);

            // Clean up.
            GC.Collect();
            Promise.Manager.HandleCompletesAndProgress();
            LogAssert.NoUnexpectedReceived();
        }
Пример #15
0
        public void ThrowingRejectExceptionInOnResolvedRejectsThePromiseWithTheGivenValue()
        {
            var promise1 = Promise.Resolved();
            var promise2 = Promise.Resolved(100);

            int    voidRejections = 0;
            int    intRejections  = 0;
            string expected       = "Reject!";

            Action <Promise> callback = p =>
            {
                p.Catch((string e) =>
                {
                    Assert.AreEqual(expected, e);
                    ++voidRejections;
                });
                throw Promise.RejectException(expected);
            };
            Action <Promise> callbackT = p =>
            {
                p.Catch((string e) =>
                {
                    Assert.AreEqual(expected, e);
                    ++intRejections;
                });
                throw Promise.RejectException(expected);
            };

            TestHelper.AddResolveCallbacks <int, string>(promise1,
                                                         promiseToVoid: callback,
                                                         promiseToConvert: p => { callback(p); return(0); },
                                                         promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                         promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                         );
            TestHelper.AddCallbacks <int, object, string>(promise1,
                                                          promiseToVoid: callback,
                                                          promiseToConvert: p => { callback(p); return(0); },
                                                          promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                          promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                          );
            TestHelper.AddContinueCallbacks <int, string>(promise1,
                                                          promiseToVoid: callback,
                                                          promiseToConvert: p => { callback(p); return(0); },
                                                          promiseToPromise: p => { callback(p); return(Promise.Resolved()); },
                                                          promiseToPromiseConvert: p => { callback(p); return(Promise.Resolved(0)); }
                                                          );

            TestHelper.AddResolveCallbacks <int, string>(promise2,
                                                         promiseToVoid: callbackT,
                                                         promiseToConvert: p => { callbackT(p); return(0); },
                                                         promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                         promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(0)); }
                                                         );
            TestHelper.AddCallbacks <int, bool, object, string>(promise2,
                                                                promiseToVoid: callbackT,
                                                                promiseToConvert: p => { callbackT(p); return(false); },
                                                                promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                                promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(false)); }
                                                                );
            TestHelper.AddContinueCallbacks <int, int, string>(promise2,
                                                               promiseToVoid: callbackT,
                                                               promiseToConvert: p => { callbackT(p); return(0); },
                                                               promiseToPromise: p => { callbackT(p); return(Promise.Resolved()); },
                                                               promiseToPromiseConvert: p => { callbackT(p); return(Promise.Resolved(0)); }
                                                               );

            Promise.Manager.HandleCompletes();

            Assert.AreEqual(
                (TestHelper.resolveVoidVoidCallbacks + TestHelper.resolveVoidConvertCallbacks +
                 TestHelper.resolveVoidPromiseVoidCallbacks + TestHelper.resolveVoidPromiseConvertCallbacks +
                 TestHelper.continueVoidVoidCallbacks + TestHelper.continueVoidConvertCallbacks +
                 TestHelper.continueVoidPromiseVoidCallbacks + TestHelper.continueVoidPromiseConvertCallbacks) * 2,
                voidRejections
                );
            Assert.AreEqual(
                (TestHelper.resolveTVoidCallbacks + TestHelper.resolveTConvertCallbacks +
                 TestHelper.resolveTPromiseVoidCallbacks + TestHelper.resolveTPromiseConvertCallbacks +
                 TestHelper.continueTVoidCallbacks + TestHelper.continueTConvertCallbacks +
                 TestHelper.continueTPromiseVoidCallbacks + TestHelper.continueTPromiseConvertCallbacks) * 2,
                intRejections
                );

            TestHelper.Cleanup();
        }