public void TryRemove_ShouldLogException_WhenLoggerIsGiven_AndIdIsGiven_AndTapThrowsException(bool expected) { // Arrange const int id = 7; _mockInner .Setup(u => u.TryRemove(id)) .Returns(expected); _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 var result = subject.TryRemove(id); // Assert result.Should().Be(expected); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void TryRemove_ShouldDoNothing_WhenEntityIsGiven_AndTapThrowsException(bool expected) { // Arrange var person = new FakeEntity <int> { Id = 7, Name = "Tiffany" }; _mockInner .Setup(u => u.TryRemove(person)) .Returns(expected); _mockTap .Setup(u => u.Remove(person)) .Throws(new InvalidOperationException()); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object); // Act var result = subject.TryRemove(person); // Assert result.Should().Be(expected); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void TryRemove_ShouldSkipTap_WhenLoggerIsGiven_AndIdIsGiven_InnerThrowsException() { // Arrange const int id = 7; _mockInner .Setup(u => u.TryRemove(id)) .Throws(new InvalidOperationException()); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act Action action = () => subject.TryRemove(id); // Assert action.Should().Throw <InvalidOperationException>(); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void TryRemove_ShouldCallInner_AndTap_WhenLoggerIsGiven_AndIdIsGiven(bool expected) { // Arrange const int id = 7; _mockInner .Setup(u => u.TryRemove(id)) .Returns(expected); _mockTap.Setup(u => u.Remove(id)); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act var result = subject.TryRemove(id); // Assert result.Should().Be(expected); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void TryRemove_ShouldSkipTap_WhenEntityIsGiven_AndInnerThrowsException() { // Arrange var person = new FakeEntity <int> { Id = 7, Name = "Tiffany" }; _mockInner .Setup(u => u.TryRemove(person)) .Throws(new InvalidOperationException()); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object); // Act Action action = () => subject.TryRemove(person); // Assert action.Should().Throw <InvalidOperationException>(); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }
public void TryRemove_ShouldCallInner_AndTap_WhenLoggerIsGiven_AndEntityIsGiven(bool expected) { // Arrange var person = new FakeEntity <int> { Id = 7, Name = "Tiffany" }; _mockInner .Setup(u => u.TryRemove(person)) .Returns(expected); _mockTap.Setup(u => u.Remove(person)); var subject = new CommandServiceTap <FakeEntity <int>, int>(_mockInner.Object, _mockTap.Object, _mockLogger.Object); // Act var result = subject.TryRemove(person); // Assert result.Should().Be(expected); _mockInner.VerifyAll(); _mockTap.VerifyAll(); _mockLogger.VerifyAll(); }