public int CompareTo(GallioTestElement other) { // Find common ancestor. var branches = new Dictionary <GallioTestElement, GallioTestElement>(); for (GallioTestElement thisAncestor = this, thisBranch = null; thisAncestor != null; thisBranch = thisAncestor, thisAncestor = thisAncestor.Parent as GallioTestElement) { branches.Add(thisAncestor, thisBranch); } for (GallioTestElement otherAncestor = other, otherBranch = null; otherAncestor != null; otherBranch = otherAncestor, otherAncestor = otherAncestor.Parent as GallioTestElement) { GallioTestElement thisBranch; if (branches.TryGetValue(otherAncestor, out thisBranch)) { // Compare the relative ordering of the branches leading from // the common ancestor to each child. int thisOrder = thisBranch != null?otherAncestor.children.IndexOf(thisBranch) : -1; int otherOrder = otherBranch != null?otherAncestor.children.IndexOf(otherBranch) : -1; return(thisOrder.CompareTo(otherOrder)); } } // No common ancestor, compare test ids. return(testId.CompareTo(other.testId)); }
public static GallioTestElement CreateFromTest(TestData test, ICodeElementInfo codeElement, IUnitTestProvider provider, GallioTestElement parent) { if (test == null) throw new ArgumentNullException("test"); // The idea here is to generate a test element object that does not retain any direct // references to the code element info and other heavyweight objects. A test element may // survive in memory for quite a long time so we don't want it holding on to all sorts of // irrelevant stuff. Basically we flatten out the test to just those properties that we // need to keep. var element = new GallioTestElement(provider, parent, test.Id, test.Name, test.Metadata.GetValue(MetadataKeys.TestKind) ?? "Unknown", test.IsTestCase, ReSharperReflectionPolicy.GetProject(codeElement), ReSharperReflectionPolicy.GetDeclaredElementResolver(codeElement), GetAssemblyPath(codeElement), GetTypeName(codeElement), GetNamespaceName(codeElement)); var categories = test.Metadata[MetadataKeys.Category]; if (categories.Count != 0) element.Categories = UnitTestElementCategory.Create(categories); var reason = test.Metadata.GetValue(MetadataKeys.IgnoreReason); if (reason != null) element.ExplicitReason = reason; return element; }
protected GallioTestElement(IUnitTestProvider provider, GallioTestElement parent, string testId, string testName, string kind, bool isTestCase, IProject project, IDeclaredElementResolver declaredElementResolver, string assemblyPath, string typeName, string namespaceName) : base(provider, testId, parent) { this.testId = testId; this.testName = testName; this.kind = kind; this.isTestCase = isTestCase; this.project = project; this.declaredElementResolver = declaredElementResolver; this.assemblyPath = assemblyPath; this.typeName = typeName; this.namespaceName = namespaceName; }
public static GallioTestElement CreateFromTest(TestData test, ICodeElementInfo codeElement, IUnitTestProvider provider, GallioTestElement parent) { if (test == null) { throw new ArgumentNullException("test"); } // The idea here is to generate a test element object that does not retain any direct // references to the code element info and other heavyweight objects. A test element may // survive in memory for quite a long time so we don't want it holding on to all sorts of // irrelevant stuff. Basically we flatten out the test to just those properties that we // need to keep. var element = new GallioTestElement(provider, parent, test.Id, test.Name, test.Metadata.GetValue(MetadataKeys.TestKind) ?? "Unknown", test.IsTestCase, ReSharperReflectionPolicy.GetProject(codeElement), ReSharperReflectionPolicy.GetDeclaredElementResolver(codeElement), GetAssemblyPath(codeElement), GetTypeName(codeElement), GetNamespaceName(codeElement)); var categories = test.Metadata[MetadataKeys.Category]; if (categories.Count != 0) { element.Categories = UnitTestElementCategory.Create(categories); } var reason = test.Metadata.GetValue(MetadataKeys.IgnoreReason); if (reason != null) { element.ExplicitReason = reason; } return(element); }
public int CompareTo(GallioTestElement other) { // Find common ancestor. var branches = new Dictionary<GallioTestElement, GallioTestElement>(); for (GallioTestElement thisAncestor = this, thisBranch = null; thisAncestor != null; thisBranch = thisAncestor, thisAncestor = thisAncestor.Parent as GallioTestElement) branches.Add(thisAncestor, thisBranch); for (GallioTestElement otherAncestor = other, otherBranch = null; otherAncestor != null; otherBranch = otherAncestor, otherAncestor = otherAncestor.Parent as GallioTestElement) { GallioTestElement thisBranch; if (branches.TryGetValue(otherAncestor, out thisBranch)) { // Compare the relative ordering of the branches leading from // the common ancestor to each child. int thisOrder = thisBranch != null ? otherAncestor.children.IndexOf(thisBranch) : -1; int otherOrder = otherBranch != null ? otherAncestor.children.IndexOf(otherBranch) : -1; return thisOrder.CompareTo(otherOrder); } } // No common ancestor, compare test ids. return testId.CompareTo(other.testId); }
public bool Equals(GallioTestElement other) { return other != null && testId == other.testId; }
public int CompareTo(object obj) { GallioTestElement other = obj as GallioTestElement; return(other != null?CompareTo(other) : 1); // sort gallio test elements after all other kinds }
public bool Equals(GallioTestElement other) { return(other != null && testId == other.testId); }