예제 #1
0
        public void GetLoadExceptionDetailsShouldLogUniqueExceptionsOnly()
        {
            var loaderException = new AccessViolationException("DummyLoaderExceptionMessage2");
            var exceptions      = new ReflectionTypeLoadException(null, new Exception[] { loaderException, loaderException });

            Assert.AreEqual(
                string.Concat(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resource.EnumeratorLoadTypeErrorFormat,
                        loaderException.GetType(),
                        loaderException.Message),
                    "\r\n"),
                this.assemblyEnumerator.GetLoadExceptionDetails(exceptions));
        }
예제 #2
0
        public void GetLoadExceptionDetailsShouldReturnLoaderExceptionMessagesForMoreThanOneException()
        {
            var loaderException1 = new ArgumentNullException("DummyLoaderExceptionMessage1", (Exception)null);
            var loaderException2 = new AccessViolationException("DummyLoaderExceptionMessage2");
            var exceptions       = new ReflectionTypeLoadException(
                null,
                new Exception[] { loaderException1, loaderException2 });
            StringBuilder errorDetails = new StringBuilder();

            errorDetails.AppendFormat(
                CultureInfo.CurrentCulture,
                Resource.EnumeratorLoadTypeErrorFormat,
                loaderException1.GetType(),
                loaderException1.Message).AppendLine();
            errorDetails.AppendFormat(
                CultureInfo.CurrentCulture,
                Resource.EnumeratorLoadTypeErrorFormat,
                loaderException2.GetType(),
                loaderException2.Message).AppendLine();

            Assert.AreEqual(errorDetails.ToString(), this.assemblyEnumerator.GetLoadExceptionDetails(exceptions));
        }