public void Remove_ShouldCallInner_AndTap_WhenLoggerIsGiven_AndIdIsGiven() { // Arrange const int id = 7; _mockInner.Setup(u => u.Remove(id)); _mockTap.Setup(u => u.Remove(id)); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act subject.Remove(id); // Assert _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void Remove_ShouldDoNothing_WhenIdIsGiven_AndTapThrowsException() { // Arrange const int id = 7; _mockInner.Setup(u => u.Remove(id)); _mockTap .Setup(u => u.Remove(id)) .Throws(new InvalidOperationException()); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object); // Act subject.Remove(id); // Assert _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void Remove_ShouldCallInner_AndTap_WhenLoggerIsGiven_AndEntityIsGiven() { // Arrange var person = new FakeEntity <int> { Id = 7, Name = "Tiffany" }; _mockInner.Setup(u => u.Remove(person)); _mockTap.Setup(u => u.Remove(person)); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act subject.Remove(person); // Assert _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void Remove_ShouldLogException_WhenLoggerIsGiven_AndIdIsGiven_AndTapThrowsException() { // Arrange const int id = 7; _mockInner.Setup(u => u.Remove(id)); _mockTap .Setup(u => u.Remove(id)) .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 CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act subject.Remove(id); // Assert _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void Remove_ShouldSkipTap_WhenLoggerIsGiven_AndIdIsGiven_AndInnerThrowsException() { // Arrange const int id = 7; _mockInner .Setup(u => u.Remove(id)) .Throws(new InvalidOperationException()); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act Action action = () => subject.Remove(id); // Assert action.Should().Throw <InvalidOperationException>(); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void Remove_ShouldDoNothing_WhenEntityIsGiven_AndTapThrowsException() { // Arrange var person = new FakeEntity <int> { Id = 7, Name = "Tiffany" }; _mockInner.Setup(u => u.Remove(person)); _mockTap .Setup(u => u.Remove(person)) .Throws(new InvalidOperationException()); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object); // Act subject.Remove(person); // Assert _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }