/// <summary> /// Process the loaded XML for a test assembly. /// </summary> /// <param name="graphRoot">The root assemblies.</param> /// <param name="xml">The loaded test results XML.</param> private void ProcessXml(List <TestAssembly> graphRoot, string xml) { var doc = new XmlDocument(); doc.LoadXml(xml); var tests = doc.DocumentElement.ChildNodes[2]; foreach (XmlNode child in tests.ChildNodes) { if (child.Name == "UnitTestResult") { var testName = child.Attributes.GetNamedItem("testName").InnerText; var duration = TimeSpan.Parse(child.Attributes.GetNamedItem("duration").InnerText); var parts = TestNameParser(testName); var assembly = parts[0]; parts.RemoveAt(0); var group = parts[0]; string iteration = null; parts.RemoveAt(0); if (parts[parts.Count - 1].StartsWith("(")) { iteration = parts[parts.Count - 1]; parts.RemoveAt(parts.Count - 1); } var test = string.Join(" ", parts); TestIterationResult iterationResult = null; if (!string.IsNullOrWhiteSpace(iteration)) { iterationResult = new TestIterationResult { Iteration = iteration, DurationTicks = duration.Ticks, }; } // test? var testResult = graphRoot.SelectMany(r => r.TestGroups) .SelectMany(g => g.TestResults) .SingleOrDefault(t => t.TestName == test); if (testResult == null) { testResult = new TestResult { TestName = test, DurationTicks = iterationResult == null ? duration.Ticks : 0, }; if (iterationResult != null) { testResult.AddIteration(iterationResult); } // group? var groupResult = graphRoot.SelectMany(r => r.TestGroups) .SingleOrDefault(g => g.GroupName == group); if (groupResult == null) { groupResult = new TestGroup { GroupName = group, DurationTicks = 0, }; groupResult.AddTestResult(testResult); // assembly? var testAssembly = graphRoot.SingleOrDefault( a => a.AssemblyName == assembly); if (testAssembly == null) { testAssembly = new TestAssembly { AssemblyName = assembly, DurationTicks = 0, }; testAssembly.AddGroup(groupResult); graphRoot.Add(testAssembly); } else { testAssembly.AddGroup(groupResult); } } else { groupResult.AddTestResult(testResult); } } if (iterationResult != null) { testResult.AddIteration(iterationResult); } } } }