public void Message_NullMessageWithInnerException() { // Issue 343: If there is no message but there is an inner exception specified, the main exception message should be modified. var inner = new Exception("Can't find file."); var dre = new DependencyResolutionException(null, inner); Assert.True(dre.Message.Contains("Can't find file."), "The exception message should include the inner exception message."); }
/// <summary> /// Tries to find any configuration problems /// by going through each of the services registered and trying to resolve them. /// </summary> /// <param name="container">The container.</param> /// <returns>A list of exceptions from resolve attemps or an empty list if no problems were found.</returns> public static IList<Exception> FindConfigurationProblems(this IContainer container) { var services = container .ComponentRegistry .Registrations .SelectMany(x => x.Services) .OfType<TypedService>() .Where(x => !x.ServiceType.Name.StartsWith("Autofac")) .ToList(); var exceptions = new List<Exception>(); foreach (var typedService in services) { try { container.Resolve(typedService.ServiceType); } catch (DependencyResolutionException ex) { var e = new DependencyResolutionException( string.Format("Unable to resolve service '{0}'. {1}", typedService.ServiceType.FullName, ex.Message), ex); exceptions.Add(e); } } return exceptions; }
public void Message_InnerExceptionMessageIncluded() { // Issue 343: The inner exception message should be included in the main exception message. var inner = new Exception("Can't find file."); var dre = new DependencyResolutionException("Unable to resolve component.", inner); Assert.True(dre.Message.Contains("Can't find file."), "The exception message should include the inner exception message."); }
public void Message_NullInnerException() { // Issue 343: If there is a null inner exception specified, the main exception message should not be modified. var dre = new DependencyResolutionException("Unable to resolve component.", null); Assert.Equal("Unable to resolve component.", dre.Message); }
public void Message_NoMessageOrInnerException() { // Issue 343: If there is no message or inner exception specified, the main exception message should not be modified. var dre = new DependencyResolutionException(null); Assert.True(dre.Message.Contains("Autofac.Core.DependencyResolutionException"), "The exception message should be the default exception message."); }
public void Message_NullMessageWithInnerException() { var inner = new FileNotFoundException("Can't find file."); var dre = new DependencyResolutionException(null, inner); Assert.IsTrue(dre.Message.Contains("Can't find file."), "The exception message should include the inner exception message."); }
public void Message_NullInnerException() { var dre = new DependencyResolutionException("Unable to resolve component.", null); Assert.AreEqual("Unable to resolve component.", dre.Message, "The message should not be modified if there is no inner exception."); }
public void Message_NoMessageOrInnerException() { var dre = new DependencyResolutionException(null); Assert.AreEqual("Exception of type 'Autofac.Core.DependencyResolutionException' was thrown.", dre.Message, "The message should not be modified if there is no inner exception."); }
public void Message_InnerExceptionMessageIncluded() { var inner = new FileNotFoundException("Can't find file."); var dre = new DependencyResolutionException("Unable to resolve component.", inner); Assert.IsTrue(dre.Message.Contains("Can't find file."), "The exception message should include the inner exception message."); }
public void Message_NoMessageOrInnerException() { // Issue 343: If there is no message or inner exception specified, the main exception message should not be modified. var dre = new DependencyResolutionException(null); Assert.Equal("Exception of type 'Autofac.Core.DependencyResolutionException' was thrown.", dre.Message); }