示例#1
0
        public void ApproveErrorLog_NoExceptions()
        {
            var exception = new ReflectionTypeLoadException(new Type[0], new Exception[0]);

            var formattedException = AssemblyScanner.FormatReflectionTypeLoadException("MyFile", exception);

            Approver.Verify(formattedException);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }