public void TestThatLogExceptionThrowsArgumentNullExceptionIfDeliveryEngineValidateExceptionIsNull() { using (var exceptionLogger = new ExceptionLogger(GetPathForExceptionLogger())) { Assert.That(exceptionLogger, Is.Not.Null); DeliveryEngineValidateException exception = null; // ReSharper disable ExpressionIsAlwaysNull Assert.Throws <ArgumentNullException>(() => exceptionLogger.LogException(exception)); // ReSharper restore ExpressionIsAlwaysNull exceptionLogger.Dispose(); } Assert.That(GetNumberOfLogFiles(), Is.EqualTo(0)); }
/// <summary> /// Log a validation exception in the delivery engine. /// </summary> /// <param name="exception">Validation exception from the delivery engine.</param> public virtual void LogException(DeliveryEngineValidateException exception) { if (exception == null) { throw new ArgumentNullException("exception"); } try { Trace.TraceError("{0} ({1}): {2}, StackTrace: {3}", exception.GetType().Name, exception.Information.ExceptionInfo, exception.Message, exception.StackTrace); Trace.Flush(); } // ReSharper disable EmptyGeneralCatchClause catch { } // ReSharper restore EmptyGeneralCatchClause }
public void TestThatConstructurDeliveryEngineValidateExceptionWithoutInnerException() { var fixture = new Fixture(); fixture.Customize <IDeliveryEngineValidateExceptionInfo>(e => e.FromFactory(() => MockRepository.GenerateMock <IDeliveryEngineValidateExceptionInfo>())); var message = fixture.CreateAnonymous <string>(); var information = fixture.CreateAnonymous <IDeliveryEngineValidateExceptionInfo>(); var exception = new DeliveryEngineValidateException(message, information); Assert.That(exception, Is.Not.Null); Assert.That(exception.Message, Is.Not.Null); Assert.That(exception.Message, Is.Not.Empty); Assert.That(exception.Message, Is.EqualTo(message)); Assert.That(exception.Information, Is.Not.Null); Assert.That(exception.Information, Is.EqualTo(information)); Assert.That(exception.InnerException, Is.Null); }