private bool EvalTestPartPredicate(IDeclaredElement element, Predicate <TestPart> predicate)
            {
#if RESHARPER_45_OR_NEWER
                using (ReadLockCookie.Create())
#endif
                {
                    if (!element.IsValid())
                    {
                        return(false);
                    }

                    try
                    {
                        PsiReflectionPolicy reflectionPolicy = new PsiReflectionPolicy(element.GetManager());
                        ICodeElementInfo    elementInfo      = reflectionPolicy.Wrap(element);
                        if (elementInfo == null)
                        {
                            return(false);
                        }

                        ITestDriver      driver    = CreateTestDriver();
                        IList <TestPart> testParts = driver.GetTestParts(reflectionPolicy, elementInfo);
                        return(GenericCollectionUtils.Exists(testParts, predicate));
                    }
                    catch (Exception ex)
                    {
                        HandleEmbeddedProcessCancelledException(ex);
                        throw;
                    }
                }
            }
Exemple #2
0
        public bool IsTest(string assembly, string member)
        {
            if (!_isInitialized)
            {
                return(false);
            }
            MemberInfo mem = getTestFromName(assembly, member);

            if (mem == null)
            {
                return(false);
            }
            IMemberInfo      memberInfo = Gallio.Common.Reflection.Reflector.Wrap(mem);
            IList <TestPart> testParts  = _testDriver.GetTestParts(Reflector.NativeReflectionPolicy, memberInfo);

            foreach (TestPart testPart in testParts)
            {
                if (testPart.IsTest)
                {
                    return(true);
                }
            }
            return(false);
        }