public override void Visit(IMethodDefinition method)
        {
            ScannedMethods++;
            _currentTestMethod = method.Attributes.Any(a =>
            {
                var attrType = a.Type as INamespaceTypeReference;
                return(attrType != null && attrType.GetTypeFullName().IsIn("NUnit.Framework.TestAttribute", "Xunit.FactAttribute" /*, "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute"*/));
            }) ? method : null;

            if (_currentTestMethod != null && _searcher.Matches(_currentTestMethod))
            {
                _log.Debug("selected test method: " + _currentTestMethod);
                IsChoiceError = true;
            }
        }
        public AssemblyNode CreateAssemblyNode(IModuleInfo module,
                                               ICodePartsMatcher matcher)
        {
            var assemblyNode = new AssemblyNode(module.Name);

            assemblyNode.AssemblyPath = module.Module.Location.ToFilePathAbs();
            System.Action <CheckedNode, ICollection <INamedTypeDefinition> > typeNodeCreator = (parent, leafTypes) =>
            {
                foreach (INamedTypeDefinition typeDefinition in leafTypes)
                {
                    // _log.Debug("For types: matching: ");
                    if (matcher.Matches(typeDefinition))
                    {
                        var type = new TypeNode(parent, typeDefinition.Name.Value);
                        foreach (var method in typeDefinition.Methods)
                        {
                            if (matcher.Matches(method))
                            {
                                type.Children.Add(new MethodNode(type, method.Name.Value, method, false));
                            }
                        }
                        parent.Children.Add(type);
                    }
                }
            };
            Func <INamedTypeDefinition, string> namespaceExtractor = typeDef =>
                                                                     TypeHelper.GetDefiningNamespace(typeDef).Name.Value;


            NamespaceGrouper <INamespaceTypeDefinition, CheckedNode> .
            GroupTypes(assemblyNode,
                       namespaceExtractor,
                       (parent, name) => new TypeNamespaceNode(parent, name),
                       typeNodeCreator,
                       module.Module.GetAllTypes().ToList());


            //remove empty amespaces.
            //TODO to refactor...
            List <TypeNamespaceNode> checkedNodes = assemblyNode.Children.OfType <TypeNamespaceNode>().ToList();

            foreach (TypeNamespaceNode node in checkedNodes)
            {
                RemoveFromParentIfEmpty(node);
            }
            return(assemblyNode);
        }
        public AssemblyNode CreateAssemblyNode(IModuleInfo module, 
            ICodePartsMatcher matcher)
        {
            var assemblyNode = new AssemblyNode(module.Name);
            assemblyNode.AssemblyPath = module.Module.Location.ToFilePathAbs();
            System.Action<CheckedNode, ICollection<INamedTypeDefinition>> typeNodeCreator = (parent, leafTypes) =>
            {
                foreach (INamedTypeDefinition typeDefinition in leafTypes)
                {
                   // _log.Debug("For types: matching: ");
                    if (matcher.Matches(typeDefinition))
                    {
                        var type = new TypeNode(parent, typeDefinition.Name.Value);
                        foreach (var method in typeDefinition.Methods)
                        {
                            if (matcher.Matches(method))
                            {
                                type.Children.Add(new MethodNode(type, method.Name.Value, method, false));
                            }
                        }
                        parent.Children.Add(type);
                    }
                }
            };
            Func<INamedTypeDefinition, string> namespaceExtractor = typeDef =>
                TypeHelper.GetDefiningNamespace(typeDef).Name.Value;


            NamespaceGrouper<INamespaceTypeDefinition, CheckedNode>.
                GroupTypes(assemblyNode,
                    namespaceExtractor,
                    (parent, name) => new TypeNamespaceNode(parent, name),
                    typeNodeCreator,
                        module.Module.GetAllTypes().ToList());


            //remove empty amespaces. 
            //TODO to refactor...
            List<TypeNamespaceNode> checkedNodes = assemblyNode.Children.OfType<TypeNamespaceNode>().ToList();
            foreach (TypeNamespaceNode node in checkedNodes)
            {
                RemoveFromParentIfEmpty(node);
            }
            return assemblyNode;
        }
 public static ICodePartsMatcher Join(this ICodePartsMatcher matcher, ICodePartsMatcher matcher2)
     {
         return new DelegatingMatcher(
             reff => matcher.Matches(reff) && matcher2.Matches(reff),
             reff => matcher.Matches(reff) && matcher2.Matches(reff));
     }
Esempio n. 5
0
 public static ICodePartsMatcher Join(this ICodePartsMatcher matcher, ICodePartsMatcher matcher2)
 {
     return(new DelegatingMatcher(
                reff => matcher.Matches(reff) && matcher2.Matches(reff),
                reff => matcher.Matches(reff) && matcher2.Matches(reff)));
 }