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

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
Esempio n. 2
0
        public void ResultIsCancelled()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsTrue(args.WasCancelled);
        }
Esempio n. 3
0
        public void Rescue_RescuesAllErrors()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
Esempio n. 4
0
        public void RescueSpecific_IgnoresOtherThrownExceptions()
        {
            var sut = new RescueResultDecorator<IOException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.AreSame(_error, args.Error);
        }
Esempio n. 5
0
        public void RescueSpecific_RescuesSpecificThrownException()
        {
            var sut = new RescueResultDecorator<ArgumentException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

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

            var args = sut.BlockingExecute();

            Assert.AreSame(_error, args.Error);
        }
Esempio n. 7
0
        public void Rescue_RescuesAllThrownExceptions()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
Esempio n. 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);
        }
        public void ResultStillCompletes()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsFalse(args.WasCancelled);
            Assert.IsNull(args.Error);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 14
0
        public void RescueCoroutineIsExecutedOnSameContext()
        {
            var _context = new ActionExecutionContext();

            var resultMock = new Mock<IResult>();
            resultMock.Setup(x => x.Execute(_context))
                .Verifiable();

            Func<Exception, IEnumerable<IResult>> handler = ex => resultMock.Object.AsCoroutine();

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

            sut.Execute(_context);

            resultMock.Verify();
        }
        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);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        public void RescueCoroutineIsExecutedOnSameContext()
        {
            var _context = new ActionExecutionContext();

            var resultMock = new Mock <IResult>();

            resultMock.Setup(x => x.Execute(_context))
            .Verifiable();

            Func <Exception, IEnumerable <IResult> > handler = ex => resultMock.Object.AsCoroutine();

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

            sut.Execute(_context);

            resultMock.Verify();
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        public void ResultIsCancelled()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsTrue(args.WasCancelled);
        }