예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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>();
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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>();
        }
예제 #7
0
        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>());
        }
예제 #8
0
        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>());
        }
예제 #9
0
		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;
		}