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(); }
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(); }
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(); }
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(); }