public void Update_ShouldNotCatchException_WhenInnerThrowsException_AndTypeIsWrong(bool handlerReturnValue)
        {
            // Arrange
            var entity = new FakeEntity <int> {
                Id = 5
            };
            InvalidOperationException actualException = null;

            _mockInner
            .Setup(i => i.Update(entity))
            .Throws(new Exception());

            var subject = new CommandServiceExceptionHandler <FakeEntity <int>, int, InvalidOperationException>(_mockInner.Object, ex =>
            {
                actualException = ex;
                return(handlerReturnValue);
            });

            // Act
            Action action = () => subject.Update(entity);

            // Assert
            action.Should().Throw <Exception>();
            actualException.Should().BeNull();

            _mockInner.VerifyAll();
        }
        public void Update_ShouldInvokeHandler_WhenInnerThrowsException_AndHandlerReturnsTrue()
        {
            // Arrange
            var entity = new FakeEntity <int> {
                Id = 5
            };
            var expectedException = new InvalidOperationException();
            InvalidOperationException actualException = null;

            _mockInner
            .Setup(i => i.Update(entity))
            .Throws(expectedException);

            var subject = new CommandServiceExceptionHandler <FakeEntity <int>, int, InvalidOperationException>(_mockInner.Object, ex =>
            {
                actualException = ex;
                return(true);
            });

            // Act
            subject.Update(entity);

            // Assert
            actualException.Should().BeSameAs(expectedException);
            _mockInner.VerifyAll();
        }
        public void Update_ShouldCallInner(bool handlerReturnValue)
        {
            // Arrange
            var entity = new FakeEntity <int> {
                Id = 5
            };
            InvalidOperationException actualException = null;

            _mockInner.Setup(i => i.Update(entity));

            var subject = new CommandServiceExceptionHandler <FakeEntity <int>, int, InvalidOperationException>(_mockInner.Object, ex =>
            {
                actualException = ex;
                return(handlerReturnValue);
            });

            // Act
            subject.Update(entity);

            // Assert
            actualException.Should().BeNull();
            _mockInner.VerifyAll();
        }