private static XElement GetResult(TestCaseResultServerEvent resultServerEvent)
{
Func<TestCaseResultServerEvent, string> formatName =
resultX => resultX.FullMethodName();
XElement otherInfoElement = null;
if (!string.IsNullOrEmpty(resultServerEvent.OtherInfo))
{
otherInfoElement = new XElement("otherInfo", resultServerEvent.OtherInfo);
}
XElement exceptionInfoElement = null;
if (resultServerEvent.ExceptionInfo != null)
{
exceptionInfoElement = FormatExceptionInfoElement(resultServerEvent.ExceptionInfo);
}
XElement metaData = null;
if (resultServerEvent.Metadata.Any())
{
metaData = new XElement("metaDataItems", from md in resultServerEvent.Metadata
select new XElement("metaData",
new XAttribute("classification", md.Classification),
new XAttribute("name", md.Name),
md.Value));
}
return new XElement("test",
new XAttribute("name", formatName(resultServerEvent)),
new XAttribute("resulttype", resultServerEvent.ResultType),
new XAttribute("timeToComplete", resultServerEvent.TimeToComplete.ToString()),
exceptionInfoElement,
otherInfoElement,
metaData
);
}