Ejemplo n.º 1
0
 private static void InitCache(string patterns)
 {
     var lines = patterns.Split(';');
     foreach (var line in lines)
     {
         var parameters = line.Split(',');
         var testFrameworkId = (TestFramework)Enum.Parse(typeof(TestFramework), parameters[0]);
         Exceptions[testFrameworkId] = new ExceptionConstructor(parameters[1], parameters[2], parameters[3], parameters[4]);
     }
     ExceptionScanner();
 }
Ejemplo n.º 2
0
        private static ExceptionConstructor ExceptionScanner(string assemblyMarker, string nameSpace, string assertionExceptionName, string ignoreExceptionName, string inconclusiveExceptionName)
        {
#if !(PORTABLE) && !(NETSTANDARD1_3)
            var foundExceptions  = 0;
            var result           = new ExceptionConstructor();
            var defaultSignature = new[] { typeof(string) };
            foreach (
                var assembly in
                AppDomain.CurrentDomain.GetAssemblies()
                .Where(ass => ass.FullName.ToLowerInvariant().Contains(assemblyMarker)))
            {
                var exportedTypes = assembly.GetExportedTypes();
                foreach (var type in exportedTypes)
                {
                    Debug.Assert(type.Namespace != null, "type.Namespace != null");
                    if (type.Namespace.StartsWith(nameSpace))
                    {
                        if (type.Name == assertionExceptionName)
                        {
                            var info = type.GetConstructor(defaultSignature);
                            result.FailedException = info;
                            foundExceptions++;
                        }
                        else if (type.Name == ignoreExceptionName)
                        {
                            var info = type.GetConstructor(defaultSignature);
                            result.IgnoreException = info;
                            foundExceptions++;
                        }
                        else if (type.Name == inconclusiveExceptionName)
                        {
                            var info = type.GetConstructor(defaultSignature);
                            result.InconclusiveException = info;
                            foundExceptions++;
                            if (string.IsNullOrEmpty(ignoreExceptionName))
                            {
                                // if we do not expect a ignore exception, we remap inconclusive
                                result.IgnoreException = info;
                                foundExceptions++;
                            }
                        }
                    }

                    // stop search if we found everything
                    if (foundExceptions == 3)
                    {
                        return(result);
                    }
                }
            }
#endif

            return(null);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Reset assembly cache
 /// </summary>
 public static void ResetCache()
 {
     constructors = null;
 }