예제 #1
0
        public void WaitForAllOf_Completes_WhenOneHasError()
        {
            var canThrow = false;

            var expectedException = new Exception("Test exception");
            var task = WaitForAllOf(
                Never.BoxResult(),
                WaitForCondition(
                    "Throw",
                    () =>
            {
                if (canThrow)
                {
                    throw expectedException;
                }

                return(canThrow);
            }))
                       .ExpectWithinSeconds(1)
                       .ToTask(this.Executor);

            this.AdvanceDefaultFrame();
            Assert.IsFalse(task.IsCompleted);
            Assert.IsFalse(task.IsFaulted);

            canThrow = true;
            this.AdvanceDefaultFrame();

            var exception = GetFailureException(task);

            Assert.AreSame(expectedException, exception.InnerException);
        }
예제 #2
0
        public void BoxedCondition_PublishesError_WhenTimedOut()
        {
            var task = Never
                       .BoxResult()
                       .ExpectWithinSeconds(1)
                       .ToTask(this.Executor);

            this.AdvanceDefaultFrame();
            Assert.IsFalse(task.IsFaulted);

            this.Scheduler.AdvanceFrame(OneSecond);
            Assert.IsNotNull(GetFailureException(task));
        }