public void TestDisposeCanBeCalledMoreThanOnce()
        {
            using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger()))
            {
                Assert.That(exceptionLogger, Is.Not.Null);

                exceptionLogger.Dispose();
                exceptionLogger.Dispose();
            }
        }
        public void TestThatConstructorInitializeExceptionLogger()
        {
            using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger()))
            {
                Assert.That(exceptionLogger, Is.Not.Null);

                exceptionLogger.Dispose();
            }
        }
        public void TestThatLogExceptionLogDeliveryEngineRepositoryException()
        {
            var fixture = new Fixture();

            using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger()))
            {
                Assert.That(exceptionLogger, Is.Not.Null);

                exceptionLogger.LogException(fixture.CreateAnonymous <DeliveryEngineRepositoryException>());
                exceptionLogger.Dispose();
            }
            Assert.That(GetNumberOfLogFiles(), Is.EqualTo(1));
        }
        public void TestThatLogExceptionThrowsArgumentNullExceptionIfExceptionIsNull()
        {
            using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger()))
            {
                Assert.That(exceptionLogger, Is.Not.Null);

                Exception exception = null;
                // ReSharper disable ExpressionIsAlwaysNull
                Assert.Throws <ArgumentNullException>(() => exceptionLogger.LogException(exception));
                // ReSharper restore ExpressionIsAlwaysNull
                exceptionLogger.Dispose();
            }
            Assert.That(GetNumberOfLogFiles(), Is.EqualTo(0));
        }
        public void TestDisposeReleasesInternalResources()
        {
            using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger()))
            {
                Assert.That(exceptionLogger, Is.Not.Null);

                exceptionLogger.Dispose();

                var field = exceptionLogger.GetType().GetField("_disposed", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic);
                Assert.That(field, Is.Not.Null);
// ReSharper disable PossibleNullReferenceException
                Assert.That(field.GetValue(exceptionLogger), Is.True);
// ReSharper restore PossibleNullReferenceException
            }
        }
        public void TestThatLogExceptionLogDeliveryDeliveryEngineValidateException()
        {
            var fixture = new Fixture();

            var exceptionInformationMock = MockRepository.GenerateMock <IDeliveryEngineValidateExceptionInfo>();

            exceptionInformationMock.Expect(m => m.ExceptionInfo)
            .Return(fixture.CreateAnonymous <string>())
            .Repeat.Any();
            fixture.Customize <IDeliveryEngineValidateExceptionInfo>(e => e.FromFactory(() => exceptionInformationMock));

            using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger()))
            {
                Assert.That(exceptionLogger, Is.Not.Null);

                exceptionLogger.LogException(fixture.CreateAnonymous <DeliveryEngineValidateException>());
                exceptionLogger.Dispose();
            }
            Assert.That(GetNumberOfLogFiles(), Is.EqualTo(1));
        }