コード例 #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 ResultIsCancelled()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsTrue(args.WasCancelled);
        }
コード例 #3
0
        public void Rescue_RescuesAllErrors()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
コード例 #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);
        }
コード例 #5
0
        public void RescueSpecific_RescuesSpecificThrownException()
        {
            var sut = new RescueResultDecorator<ArgumentException>(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsNull(args.Error);
        }
コード例 #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);
        }
コード例 #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 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();
        }
コード例 #15
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);
        }
コード例 #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);
        }
コード例 #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();
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #20
0
        public void ResultIsCancelled()
        {
            var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true);

            var args = sut.BlockingExecute();

            Assert.IsTrue(args.WasCancelled);
        }