예제 #1
0
        public void Commit_ShouldCallInner_AndTap_WhenLoggerIsGiven()
        {
            // Arrange
            _mockInner.Setup(u => u.Commit());
            _mockTap.Setup(u => u.Commit());

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

            // Act
            subject.Commit();

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #2
0
        public void Commit_ShouldDoNothing_WhenTapThrowsException()
        {
            // Arrange
            _mockInner.Setup(u => u.Commit());
            _mockTap
            .Setup(u => u.Commit())
            .Throws(new InvalidOperationException());

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

            // Act
            subject.Commit();

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #3
0
        public void Commit_ShouldSkipTap_WhenInnerThrowsException()
        {
            // Arrange
            _mockInner
            .Setup(u => u.Commit())
            .Throws(new InvalidOperationException());

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

            // Act
            Action action = () => subject.Commit();

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

            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }
예제 #4
0
        public void Commit_ShouldLogException_WhenLoggerIsGiven_AndTapThrowsException()
        {
            // Arrange
            _mockInner.Setup(u => u.Commit());
            _mockTap
            .Setup(u => u.Commit())
            .Throws(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 UnitOfWorkTap(_mockInner.Object, _mockTap.Object, _mockLogger.Object);

            // Act
            subject.Commit();

            // Assert
            _mockInner.VerifyAll();
            _mockTap.VerifyAll();
            _mockLogger.VerifyAll();
        }