public void RescueSpecific_RescuesSpecificErrors() { var sut = new RescueResultDecorator <ArgumentException>(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); Assert.IsNull(args.Error); }
public void ResultIsCancelled() { var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); Assert.IsTrue(args.WasCancelled); }
public void Rescue_RescuesAllErrors() { var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); Assert.IsNull(args.Error); }
public void RescueSpecific_IgnoresOtherThrownExceptions() { var sut = new RescueResultDecorator<IOException>(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); Assert.AreSame(_error, args.Error); }
public void RescueSpecific_RescuesSpecificThrownException() { var sut = new RescueResultDecorator<ArgumentException>(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); Assert.IsNull(args.Error); }
public void RescueSpecific_NotRescuesOtherErrors() { var sut = new RescueResultDecorator <IOException>(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); Assert.AreSame(_error, args.Error); }
public void Rescue_RescuesAllThrownExceptions() { var sut = new RescueResultDecorator(_inner, ex => TestHelper.EmptyCoroutine, true); var args = sut.BlockingExecute(); 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); }
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); }
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); }
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); }
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); }
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); }
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); }
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(); }