public void ApproveErrorLog_NoExceptions() { var exception = new ReflectionTypeLoadException(new Type[0], new Exception[0]); var formattedException = AssemblyScanner.FormatReflectionTypeLoadException("MyFile", exception); Approver.Verify(formattedException); }
public void ApproveErrorLog_FileLoadException_Only() { var exception = new ReflectionTypeLoadException(new Type[0], new Exception[] { new FileLoadException("File load exception", typeof(ErrorLoggingTest).Assembly.FullName), }); var formattedException = AssemblyScanner.FormatReflectionTypeLoadException("MyFile", exception); Approver.Verify(formattedException); }
public void ApproveErrorLog_GenericExceptions() { var exception = new ReflectionTypeLoadException(new Type[0], new[] { new Exception("Generic exception 1"), new Exception("Generic exception 2"), }); var formattedException = AssemblyScanner.FormatReflectionTypeLoadException("MyFile", exception); Approver.Verify(formattedException); }
public void ApproveErrorLog_FileLoadException_NServiceBus() { var exception = new ReflectionTypeLoadException(new Type[0], new[] { new Exception("Generic exception 1"), new FileLoadException("File load exception", typeof(AssemblyScanner).Assembly.FullName), new Exception("Generic exception 2"), }); var formattedException = AssemblyScanner.FormatReflectionTypeLoadException("MyFile", exception); Approver.Verify(formattedException); }
static IEnumerable <Type> GetAllowedTypes(params Assembly[] assemblies) { var types = new List <Type>(); Array.ForEach( assemblies, a => { try { types.AddRange(a.GetTypes() .Where(AssemblyScanner.IsAllowedType)); } catch (ReflectionTypeLoadException e) { var errorMessage = AssemblyScanner.FormatReflectionTypeLoadException(a.FullName, e); LogManager.GetLogger(typeof(Configure)).Warn(errorMessage); //intentionally swallow exception } }); return(types); }