public async Task CommitAsync_ShouldDoNothing_WhenTapThrowsException()
        {
            // Arrange
            _mockInner
            .Setup(u => u.CommitAsync())
            .Returns(TaskHelpers.CompletedTask);
            _mockTap
            .Setup(u => u.CommitAsync())
            .ThrowsAsync(new InvalidOperationException());

            var subject = new AsyncUnitOfWorkParallelTap(_mockInner.Object, _mockTap.Object);

            // Act
            await subject.CommitAsync().ConfigureAwait(false);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
        public async Task CommitAsync_ShouldCallInner_AndTap()
        {
            // Arrange
            _mockInner
            .Setup(r => r.CommitAsync())
            .Returns(TaskHelpers.CompletedTask);
            _mockTap
            .Setup(r => r.CommitAsync())
            .Returns(TaskHelpers.CompletedTask);

            var subject = new AsyncUnitOfWorkParallelTap(_mockInner.Object, _mockTap.Object);

            // Act
            await subject.CommitAsync().ConfigureAwait(false);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
        public async Task CommitAsync_ShouldLogException_WhenLoggerIsGiven_AndTapThrowsException()
        {
            // Arrange
            _mockInner
            .Setup(u => u.CommitAsync())
            .Returns(TaskHelpers.CompletedTask);
            _mockTap
            .Setup(u => u.CommitAsync())
            .ThrowsAsync(new InvalidOperationException());
            _mockLogger.Setup(l => l.Log(LogLevel.Warning, 0, It.IsAny <object>(), It.IsAny <InvalidOperationException>(), It.IsAny <Func <object, Exception, string> >()));

            var subject = new AsyncUnitOfWorkParallelTap(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            await subject.CommitAsync().ConfigureAwait(false);

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
        public void CommitAsync_ShouldThrowException_WhenInnerThrowsException()
        {
            // Arrange
            _mockInner
            .Setup(r => r.CommitAsync())
            .ThrowsAsync(new InvalidOperationException());
            _mockTap
            .Setup(r => r.CommitAsync())
            .Returns(TaskHelpers.CompletedTask);

            var subject = new AsyncUnitOfWorkParallelTap(_mockInner.Object, _mockTap.Object);

            // Act
            Func <Task> action = async() => await subject.CommitAsync().ConfigureAwait(false);

            // Assert
            action.Should().Throw <InvalidOperationException>();

            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockTap.VerifyAll();
        }
        public void CommitAsync_ShouldThrowException_AndLogException_WhenLoggerIsGiven_AndBothThrowExceptions()
        {
            // Arrange
            _mockInner
            .Setup(r => r.CommitAsync())
            .ThrowsAsync(new IndexOutOfRangeException());
            _mockTap
            .Setup(r => r.CommitAsync())
            .ThrowsAsync(new InvalidOperationException());
            _mockLogger.Setup(l => l.Log(LogLevel.Warning, 0, It.IsAny <object>(), It.IsAny <InvalidOperationException>(), It.IsAny <Func <object, Exception, string> >()));

            var subject = new AsyncUnitOfWorkParallelTap(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            Func <Task> action = async() => await subject.CommitAsync().ConfigureAwait(false);

            // Assert
            action.Should().Throw <IndexOutOfRangeException>();

            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockTap.VerifyAll();
        }