private IEmbeddedConfiguration NewConfiguration(int itemCount) { FileStorage rafAdapter = new FileStorage(); IStorage ioAdapter = new LoggingStorage(rafAdapter, LogFileName(itemCount)); IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration(); config.File.Storage = ioAdapter; return(config); }
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 Get_ShouldBe_OriginGet() { // Arrange const string expected = "John Doe"; _origin.Get().Returns(expected); var storage = new LoggingStorage <string>(_logger, _origin); // Act var value = storage.Get(); // Assert value.Should().Be(expected); }
public void IsExpectedException_ShouldBe_Origin_IsExpectedException(bool expected) { // Arrange var exception = new Exception(); ((IThrowsExpectedExceptions)_origin).IsExpectedException(exception).Returns(expected); var storage = new LoggingStorage <string>(_logger, _origin); // Act var result = storage.IsExpectedException(exception); // Assert result.Should().Be(expected); }
public void Get_ShouldPass_ExpectedException() { // Arrange var exception = new Exception(); _origin.When(x => x.Get()).Do(_ => throw exception); ((IThrowsExpectedExceptions)_origin).IsExpectedException(exception).Returns(true); var storage = new LoggingStorage <string>(_logger, _origin); // Act Action action = () => storage.Get(); // 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>()); }
public void Get_ShouldLog_WhenOriginThrows_ExpectedException() { // Arrange var exception = new Exception(); _origin.When(x => x.Get()).Do(_ => throw exception); ((IThrowsExpectedExceptions)_origin).IsExpectedException(exception).Returns(true); var storage = new LoggingStorage <string>(_logger, _origin); // Act try { storage.Get(); } catch { } // Assert _logger.Received().Error(Arg.Any <string>()); }
private IEmbeddedConfiguration NewConfiguration(int itemCount) { FileStorage rafAdapter = new FileStorage(); IStorage ioAdapter = new LoggingStorage(rafAdapter, LogFileName(itemCount)); IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration(); config.File.Storage = ioAdapter; return config; }