private IUnitTestElement ProcessTestClass(IClass testClass) { if (testClass.IsAbstract) return ProcessAbstractTestClass(testClass); var typeInfo = testClass.AsTypeInfo(); if (!IsValidTestClass(testClass)) return null; XunitTestClassElement testElement; if (!classes.TryGetValue(testClass, out testElement)) { var clrTypeName = testClass.GetClrName(); testElement = unitTestElementFactory.GetOrCreateTestClass(project, clrTypeName, assemblyPath, typeInfo.GetTraits()); classes.Add(testClass, testElement); } if (testElement != null) { foreach (var testMethod in IsInThisFile(testElement.Children)) testMethod.State = UnitTestElementState.Pending; // TODO: I think this might be an edge case with RunWith // We'll add Fact based methods for classes with RunWith + Facts in base classes AppendTests(testElement, typeInfo, testClass.GetAllSuperTypes()); } return testElement; }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, IProject project, string id, UnitTestElementFactory elementFactory) { var typeName = parent.GetAttribute("typeName"); var assemblyLocation = parent.GetAttribute("assemblyLocation"); // TODO: Save and load traits. Might not be necessary - they are reset when scanning the file return(elementFactory.GetOrCreateTestClass(id, project, new ClrTypeName(typeName), assemblyLocation, new OneToSetMap <string, string>())); }
private IUnitTestElement ProcessTestClass(IClass testClass) { if (IsAbstractClass(testClass)) { return(ProcessAbstractTestClass(testClass)); } var typeInfo = testClass.AsTypeInfo(); if (!IsValidTestClass(testClass)) { return(null); } XunitTestClassElement testElement; if (!classes.TryGetValue(testClass, out testElement)) { var clrTypeName = testClass.GetClrName(); testElement = unitTestElementFactory.GetOrCreateTestClass(project, clrTypeName, assemblyPath, typeInfo.GetTraits()); classes.Add(testClass, testElement); } if (testElement != null) { foreach (var testMethod in IsInThisFile(testElement.Children)) { testMethod.State = UnitTestElementState.Pending; } AppendTests(testElement, typeInfo, testClass.GetAllSuperTypes()); } return(testElement); }
internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory) { var projectId = parent.GetAttribute("projectId"); var typeName = parent.GetAttribute("typeName"); var project = (IProject)ProjectUtil.FindProjectElementByPersistentID(solution, projectId); if (project == null) { return(null); } var assemblyLocation = project.GetOutputFilePath().FullPath; // TODO: Save and load traits. Might not be necessary - they are reset when scanning the file return(unitTestElementFactory.GetOrCreateTestClass(project, new ClrTypeName(typeName), assemblyLocation, new MultiValueDictionary <string, string>())); }
private void ExploreTestClass(IProject project, IMetadataAssembly assembly, IUnitTestElementsObserver observer, ITypeInfo typeInfo, string typeName) { var classUnitTestElement = unitTestElementFactory.GetOrCreateTestClass(project, new ClrTypeName(typeName), assembly.Location.FullPath, typeInfo.GetTraits()); observer.OnUnitTestElement(classUnitTestElement); // Don't create elements for [Fact] methods when the class has [RunWith]. This // is because we don't know what the RunWith will do - it might not pay any // attention to [Fact], and if we create the elements now, they won't be // dynamic, and that can cause issues later if (!TypeUtility.HasRunWith(typeInfo)) { foreach (var methodInfo in TypeUtility.GetTestMethods(typeInfo)) { ExploreTestMethod(project, classUnitTestElement, observer, methodInfo); } } }