internal static ITestReportComponent ParseXmlNode(XmlNode node, ref ITestReportComponent component) { string TypeOfComponent = node.Attributes["type"].Value; component.TypeOfComponent = Enum.TryParse(TypeOfComponent, out TestreportComponentType reportTypComponent) ? reportTypComponent : TestreportComponentType.Null; var func = parsingFunctions[component.TypeOfComponent]; return(func(component, node)); }
public TestReportComponentBody GetTesteportItem(XmlNode node) { try { var nodeAttribute = node.Attributes["type"].Value; var componentType = Enum.TryParse(nodeAttribute, out TestreportComponentType reportItemType) ? reportItemType : TestreportComponentType.Null; if (componentType == TestreportComponentType.Body) { var testReportBody = new TestReportComponentBody(); var nodeType = node.Attributes["type"].Value; var reportType = Enum.TryParse(nodeType, out TestreportComponentType bodyType) ? bodyType : TestreportComponentType.Null; foreach (XmlNode childNode in node.ChildNodes) { if (componentType == TestreportComponentType.Body) { return(GetTesteportItem(childNode)); } ; ITestReportComponent reportComponent = TestReportComponentFactory.GetComponentFromXmlNode(childNode); ITestReportComponent intailisedTestReportComponent = PopulateTestreportComponent.ParseXmlNode(childNode, ref reportComponent); testReportBody.ListOfComponents.Add(intailisedTestReportComponent); } } return(new TestReportComponentBody() { Title = $"Error - something went wrong trying to read this object in the test report" }); } catch (XmlException ex) { Debug.WriteLine(string.Format("XmlException for test name: {0}", ex.Message)); throw ex; } }