示例#1
0
            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;
                    }
                }
            }
示例#2
0
            private bool EvalTestPartPredicate(IDeclaredElement element, Predicate <TestPart> predicate)
            {
                if (!element.IsValid())
                {
                    return(false);
                }

                try
                {
#if RESHARPER_60
                    var reflectionPolicy = new PsiReflectionPolicy(element.GetPsiServices().PsiManager);
#else
                    var reflectionPolicy = new PsiReflectionPolicy(element.GetPsiServices().PsiManager, provider.CacheManager);
#endif
                    var elementInfo = reflectionPolicy.Wrap(element);
                    if (elementInfo == null)
                    {
                        return(false);
                    }

                    var driver    = CreateTestDriver();
                    var testParts = driver.GetTestParts(reflectionPolicy, elementInfo);
                    return(GenericCollectionUtils.Exists(testParts, predicate));
                }
                catch (Exception ex)
                {
                    HandleEmbeddedProcessCancelledException(ex);
                    throw;
                }
            }
示例#3
0
            private static void PopulateCodeElementsFromTypeDeclaration(List <ICodeElementInfo> codeElements, PsiReflectionPolicy reflectionPolicy, ITypeDeclaration declaration)
            {
                if (!declaration.IsValid())
                {
                    return;
                }

                ITypeInfo typeInfo = reflectionPolicy.Wrap(declaration.DeclaredElement);

                if (typeInfo != null)
                {
                    codeElements.Add(typeInfo);
                }

                foreach (ITypeDeclaration nestedDeclaration in declaration.NestedTypeDeclarations)
                {
                    PopulateCodeElementsFromTypeDeclaration(codeElements, reflectionPolicy, nestedDeclaration);
                }
            }
 public void WrapNullReturnsNull()
 {
     Assert.IsNull(reflectionPolicy.Wrap((IDeclaredElement)null));
     Assert.IsNull(reflectionPolicy.Wrap((IEvent)null));
     Assert.IsNull(reflectionPolicy.Wrap((IField)null));
     Assert.IsNull(reflectionPolicy.Wrap((IFunction)null));
     Assert.IsNull(reflectionPolicy.Wrap((IConstructor)null));
     Assert.IsNull(reflectionPolicy.Wrap((IMethod)null));
     Assert.IsNull(reflectionPolicy.Wrap((IOperator)null));
     Assert.IsNull(reflectionPolicy.Wrap((IParameter)null));
     Assert.IsNull(reflectionPolicy.Wrap((IProperty)null));
     Assert.IsNull(reflectionPolicy.Wrap((ITypeElement)null));
     Assert.IsNull(reflectionPolicy.Wrap((ITypeParameter)null));
 }