public string GetXmlReport() { Func <IEnumerable <TestCaseResultServerEvent>, IEnumerable <XElement> > getInnerTests = result => result.Select(s => new XElement("InnerTest", new XElement("TestName", s.FullMethodName()), new XElement("TestResult", GetTestResult(s.ResultType)), new XElement("ErrorMessage", GetErrorMessage(s)) )); var firstReport = _report.First(); var report = new XElement("SummaryResult", new XElement("TestName", "StatLight Tests"), new XElement("TestResult", GetFinalResult()), new XElement("InnerTests", getInnerTests(firstReport.TestResults))); return(report.ToString()); }