protected void DumpElements(IEnumerable <IUnitTestElement> elements, string path) { using (UT.ReadLock()) { var reportedElements = new HashSet <IUnitTestElement>(elements); var roots = new HashSet <IUnitTestElement>(); var orphanedElements = new HashSet <IUnitTestElement>(); var invalidChildren = new HashSet <IUnitTestElement>(); foreach (var unitTestElement in reportedElements) { if (unitTestElement.Parent != null && !reportedElements.Contains(unitTestElement.Parent)) { orphanedElements.Add(unitTestElement); } if (unitTestElement.Parent != null && !unitTestElement.Parent.Children.Contains(unitTestElement)) { invalidChildren.Add(unitTestElement); } if (unitTestElement.Parent == null) { roots.Add(unitTestElement); } } ExecuteWithGold(path, file => { foreach (var element in OrderById(roots)) { DumpElement(file, element, reportedElements, string.Empty); } if (orphanedElements.Count > 0) { file.WriteLine(); file.WriteLine(); file.WriteLine("Section: Has parent, but parent wasn't reported"); file.WriteLine(); foreach (var element in OrderById(orphanedElements)) { DumpElement(file, element, reportedElements, string.Empty); } } if (orphanedElements.Count > 0) { file.WriteLine(); file.WriteLine(); file.WriteLine("Section: Has parent, but parent doesn't have it among children"); file.WriteLine(); foreach (var element in OrderById(invalidChildren)) { DumpElement(file, element, reportedElements, string.Empty); } } }); } }