public void ProcessBeforeInterior(ITreeNode element) { var declaration = element as IDeclaration; if (declaration == null) { return; } var navigationRange = declaration.GetNameDocumentRange().TextRange; var containingRange = declaration.GetDocumentRange().TextRange; IUnitTestElement testElement = null; var declaredElement = declaration.DeclaredElement; if (declaredElement == null || declaredElement.ShortName == SharedImplUtil.MISSING_DECLARATION_NAME) { return; } var typeMember = declaredElement as ITypeMember; if (typeMember != null && IsTestMethod(typeMember, myUnitTestAttributeCache, myProject)) { var containingType = typeMember.GetContainingType(); if (containingType != null) { var typeName = containingType.GetClrName(); var id = string.Format("{0}.{1}{2}", typeName, !containingType.GetClrName().Equals(typeName) ? containingType.ShortName + "." : string.Empty, typeMember.ShortName); testElement = myFactory.GetOrCreateTest(id, myProject, myTargetFrameworkId, typeName, typeMember.ShortName); if (navigationRange.IsValid && containingRange.IsValid) { myObserver.OnUnitTestElementDisposition(new UnitTestElementDisposition(testElement, myFile.GetSourceFile().ToProjectFile(), navigationRange, containingRange, EmptyList <IUnitTestElement> .Instance)); } } } }
private UnityTestElement GetOrCreateTest(string id, IClrTypeName typeName, string methodName) { var element = myElementFactory.GetOrCreateTest(id, myProject, myUnitTestCollector.TargetFrameworkId, typeName, methodName); return(element); }