static void Main(string[] args) { //getting path to search files Console.WriteLine("************** i20022 framework test tool *****************"); Console.WriteLine("Your current directory is: " + Directory.GetCurrentDirectory()); Console.WriteLine("Please, type the path to search for files or press enter to exit. Do not finish with /"); string path = null; while (true) { path = Console.ReadLine(); if (path.Equals("")) { return; } //testing path try { string[] directories = Directory.GetDirectories(path); break; } catch (Exception e) { Console.WriteLine("Wrong path, please type path again or press enter to exit."); } } //creating new Report instance Report report = new Report(); report.add("Teste and Validation of Framework i20022 (http://i20022.com/)"); report.addInNewLine("Testbed: " + path); report.addInNewLine(""); //Applying directory search and test run recursiveDirectorieSearchAndTestRun(path, report); //Creating Report Console.WriteLine(""); Console.Write("Creating Report..."); report.writeReportToFile(path); Console.WriteLine(" Done!!!"); //Presenting final message Console.WriteLine(""); Console.WriteLine("Number of Messages OK: " + report.getNumberOfOKMessages()); Console.WriteLine("Number of Messages Error: " + report.getNumberErrorMessages()); Console.WriteLine("Total Number of Messages: " + report.getNumberOfMessages()); Console.WriteLine(""); Console.Write("Test is finished, please press enter to exit."); Console.ReadLine(); }
static void Main(string[] args) { //getting path to search files Console.WriteLine("************** i20022 framework test tool *****************"); Console.WriteLine("Your current directory is: " + Directory.GetCurrentDirectory()); Console.WriteLine("Please, type the path to search for files or press enter to exit. Do not finish with /"); string path = null; while (true) { path = Console.ReadLine(); if (path.Equals("")) return; //testing path try { string[] directories = Directory.GetDirectories(path); break; } catch (Exception e) { Console.WriteLine("Wrong path, please type path again or press enter to exit."); } } //creating new Report instance Report report = new Report(); report.add("Teste and Validation of Framework i20022 (http://i20022.com/)"); report.addInNewLine("Testbed: " + path); report.addInNewLine(""); //Applying directory search and test run recursiveDirectorieSearchAndTestRun(path, report); //Creating Report Console.WriteLine(""); Console.Write("Creating Report..."); report.writeReportToFile(path); Console.WriteLine(" Done!!!"); //Presenting final message Console.WriteLine(""); Console.WriteLine("Number of Messages OK: " + report.getNumberOfOKMessages()); Console.WriteLine("Number of Messages Error: " + report.getNumberErrorMessages()); Console.WriteLine("Total Number of Messages: " + report.getNumberOfMessages()); Console.WriteLine(""); Console.Write("Test is finished, please press enter to exit."); Console.ReadLine(); }
public static void runTest(string path, Report report) { Console.WriteLine("..."); Console.Write("Starting Read and Write Test for file: " + path + "..."); //Creating report information report.addInNewLine("Message: " + path); String xml = File.ReadAllText(path); MessageObject mo = null; MessageDocument md = null; Object document = null; try { //Creating report information report.addInNewLine(" Convertion XML to Object: "); md = new MessageDocument(xml); document = md.ToObject(); } catch (Exception e) { Console.WriteLine("#### ERROR transforming XML to object ####"); Console.WriteLine(e.Message); //Creating report information report.add("ERROR, problem: " + e.Message); report.increaseErrors(); return; } //Creating report information report.add("OK!"); try { //Creating report information report.addInNewLine(" Convertion Object to XML: "); mo = new MessageObject(document); } catch (Exception e) { Console.WriteLine("#### ERROR transforming object to XML ####"); Console.WriteLine(e.Message); //Creating report information report.add("ERROR, problem: " + e.Message); report.increaseErrors(); return; } File.WriteAllText(path + ".test", mo.ToXml()); Console.WriteLine(" Done!!!"); //Creating report information report.add("OK!"); //test squema compliance Console.Write("Test schema compliance..."); //Creating report information DirectoryInfo mother = Directory.GetParent(path); FileInfo[] xsd = mother.GetFiles("*.xsd"); try { Validator.validate(path + ".test", xsd[0].FullName); Console.WriteLine(" OK!"); report.addInNewLine(" XSD Validation: OK!"); report.increaseOks(); } catch(Exception e) { Console.WriteLine(" Invalid!"); report.addInNewLine(" XSD Validation: Invalid! Error: " + e.Message); } }
public static void runTest(string path, Report report) { Console.WriteLine("..."); Console.Write("Starting Read and Write Test for file: " + path + "..."); //Creating report information report.addInNewLine("Message: " + path); String xml = File.ReadAllText(path); MessageObject mo = null; MessageDocument md = null; Object document = null; try { //Creating report information report.addInNewLine(" Convertion XML to Object: "); md = new MessageDocument(xml); document = md.ToObject(); } catch (Exception e) { Console.WriteLine("#### ERROR transforming XML to object ####"); Console.WriteLine(e.Message); //Creating report information report.add("ERROR, problem: " + e.Message); report.increaseErrors(); return; } //Creating report information report.add("OK!"); try { //Creating report information report.addInNewLine(" Convertion Object to XML: "); mo = new MessageObject(document); } catch (Exception e) { Console.WriteLine("#### ERROR transforming object to XML ####"); Console.WriteLine(e.Message); //Creating report information report.add("ERROR, problem: " + e.Message); report.increaseErrors(); return; } File.WriteAllText(path + ".test", mo.ToXml()); Console.WriteLine(" Done!!!"); //Creating report information report.add("OK!"); //test squema compliance Console.Write("Test schema compliance..."); //Creating report information DirectoryInfo mother = Directory.GetParent(path); FileInfo[] xsd = mother.GetFiles("*.xsd"); try { Validator.validate(path + ".test", xsd[0].FullName); Console.WriteLine(" OK!"); report.addInNewLine(" XSD Validation: OK!"); report.increaseOks(); } catch (Exception e) { Console.WriteLine(" Invalid!"); report.addInNewLine(" XSD Validation: Invalid! Error: " + e.Message); } }