public void Set_ShouldCall_OriginSet() { // Arrange const string value = "John Doe Set"; var storage = new LoggingStorage <string>(_logger, _origin); // Act storage.Set(value); // Assert _origin.Received().Set(value); }
public void Set_ShouldPass_UnexpectedException() { // Arrange _origin.When(x => x.Set(Arg.Any <string>())).Do(_ => throw new Exception()); ((IThrowsExpectedExceptions)_origin).IsExpectedException(Arg.Any <Exception>()).Returns(false); var storage = new LoggingStorage <string>(_logger, _origin); // Act Action action = () => storage.Set("ABC"); // Assert action.Should().Throw <Exception>(); }
public void Set_ShouldLog_UnexpectedException() { // Arrange _origin.When(x => x.Set(Arg.Any <string>())).Do(_ => throw new Exception()); ((IThrowsExpectedExceptions)_origin).IsExpectedException(Arg.Any <Exception>()).Returns(false); var storage = new LoggingStorage <string>(_logger, _origin); // Act try { storage.Set("ABC"); } catch { } // Assert _logger.Received().Error(Arg.Any <string>()); }