static TestReportBase ReadInputInternal(string path, ref ExitCode.ExitCodeData errorCode) { string xmlReportFile = path; if (!File.Exists(xmlReportFile)) { // the input path could be a folder, try to detect it string dir = xmlReportFile; xmlReportFile = Path.Combine(dir, XMLReport_File); if (!File.Exists(xmlReportFile)) { // still not find, may be under "Report" sub folder? try it xmlReportFile = Path.Combine(dir, XMLReport_SubDir_Report, XMLReport_File); if (!File.Exists(xmlReportFile)) { OutputWriter.WriteLine(Properties.Resources.ErrMsg_CannotFindXmlReportFile + " " + path); errorCode = ExitCode.FileNotFound; return(null); } } } // load XML from file with the specified XML schema ResultsType root = XmlReportUtilities.LoadXmlFileBySchemaType <ResultsType>(xmlReportFile); if (root == null) { errorCode = ExitCode.CannotReadFile; return(null); } // try to load the XML data as a GUI test report GUITestReport guiReport = new GUITestReport(root, xmlReportFile); if (guiReport.TryParse()) { return(guiReport); } // try to load as API test report APITestReport apiReport = new APITestReport(root, xmlReportFile); if (apiReport.TryParse()) { return(apiReport); } // try to load as BP test report BPTReport bptReport = new BPTReport(root, xmlReportFile); if (bptReport.TryParse()) { return(bptReport); } OutputWriter.WriteLine(Properties.Resources.ErrMsg_Input_InvalidFirstReportNode + " " + path); errorCode = ExitCode.InvalidInput; return(null); }
public static bool ConvertAndSave(CommandArguments args, TestReportBase input) { ConverterBase conv = null; // try to test if the input report is a GUI/API/BPT test report GUITestReport guiReport = input as GUITestReport; APITestReport apiReport = input as APITestReport; BPTReport bptReport = input as BPTReport; if (guiReport != null) { conv = new GUITestReportConverter(args, guiReport); } else if (apiReport != null) { conv = new APITestReportConverter(args, apiReport); } else if (bptReport != null) { conv = new BPTReportConverter(args, bptReport); } else { return(false); } if (!conv.Convert()) { return(false); } if (!conv.SaveFile()) { return(false); } return(true); }