예제 #1
0
        public void RescueSpecific_RescuesSpecificErrors()
        {
            var sut = new RescueResultDecorator <ArgumentException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
예제 #2
0
        public void RescueSpecific_RescuesSpecificThrownException()
        {
            var sut = new RescueResultDecorator<ArgumentException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
예제 #3
0
        public void RescueSpecific_NotRescuesOtherErrors()
        {
            var sut = new RescueResultDecorator <IOException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.AreSame(_error, args.Error);
        }
예제 #4
0
        public void ResultIsCancelled()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsTrue(args.WasCancelled);
        }
예제 #5
0
        public void RescueSpecific_IgnoresOtherThrownExceptions()
        {
            var sut = new RescueResultDecorator<IOException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.AreSame(_error, args.Error);
        }
예제 #6
0
        public void Rescue_RescuesAllErrors()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
예제 #7
0
        public void Rescue_RescuesAllThrownExceptions()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
예제 #8
0
        public void ResultStillCompletes()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsFalse(args.WasCancelled);
            Assert.IsNull(args.Error);
        }
예제 #9
0
        public void ResultStillCompletes()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsFalse(args.WasCancelled);
            Assert.IsNull(args.Error);
        }
예제 #10
0
        public void ResultFailsWhenRescueThrows()
        {
            var thrownException = new Exception();

            var sut = new RescueResultDecorator(_inner, ex => { throw thrownException; }, true);

            var args = sut.BlockingExecute();

            Assert.AreSame(thrownException, args.Error);
        }
예제 #11
0
        public void ResultFailsWhenRescueFails()
        {
            var rescueError = new Exception();

            var sut = new RescueResultDecorator(_inner,
                                                ex => TestHelper.MockResult(false, rescueError).Object.AsCoroutine(),
                                                true);

            var args = sut.BlockingExecute();

            Assert.AreSame(rescueError, args.Error);
        }
예제 #12
0
        public void RescueCoroutineIsExecuted()
        {
            Exception rescuedError = null;

            Func<Exception, IEnumerable<IResult>> handler =
                ex => new DelegateResult(() => rescuedError = ex).AsCoroutine();

            var sut = new RescueResultDecorator(_inner, handler, true);

            sut.BlockingExecute();

            Assert.AreSame(_error, rescuedError);
        }
예제 #13
0
        public void RescueCoroutineIsExecuted()
        {
            Exception rescuedError = null;

            Func <Exception, IEnumerable <IResult> > handler =
                ex => new DelegateResult(() => rescuedError = ex).AsCoroutine();

            var sut = new RescueResultDecorator(_inner, handler, true);

            sut.BlockingExecute();

            Assert.AreSame(_error, rescuedError);
        }
예제 #14
0
        public void RescueIsNotExecuted()
        {
            bool rescueInvoked = false;

            Func <Exception, IEnumerable <IResult> > rescue = ex =>
            {
                rescueInvoked = true;
                return(TestHelper.EmptyCoroutine);
            };

            var sut = new RescueResultDecorator(_inner, rescue, true);

            sut.BlockingExecute();

            Assert.IsFalse(rescueInvoked);
        }
예제 #15
0
        public void RescueIsNotExecuted()
        {
            bool rescueExecuted = false;

            Func<Exception, IEnumerable<IResult>> rescue = ex =>
                                                               {
                                                                   rescueExecuted = true;
                                                                   return TestHelper.EmptyCoroutine;
                                                               };

            var sut = new RescueResultDecorator(_inner, rescue, true);

            sut.BlockingExecute();

            Assert.IsFalse(rescueExecuted);
        }
예제 #16
0
        public void ResultFailsWhenRescueThrows()
        {
            var thrownException = new Exception();

            var sut = new RescueResultDecorator(_inner, ex => { throw thrownException; }, true);

            var args = sut.BlockingExecute();

            Assert.AreSame(thrownException, args.Error);
        }
예제 #17
0
        public void ResultFailsWhenRescueFails()
        {
            var rescueError = new Exception();

            var sut = new RescueResultDecorator(_inner,
                                                ex => TestHelper.MockResult(false, rescueError).Object.AsCoroutine(),
                                                true);

            var args = sut.BlockingExecute();

            Assert.AreSame(rescueError, args.Error);
        }
예제 #18
0
        public void ResultIsCancelled()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsTrue(args.WasCancelled);
        }