public static List <object> LoadAndReturnConfirmationExamples( XmlSchemaSet schemaSet, Func <string, Type> typeDetector, IXmlTransformer transformIncomingViaXsl, IXmlTransformer transformOutgoingViaXsl, bool validateOriginal, bool emitAndCompare, bool validateEmitted) { ITestLog testLog = new DebugLog(); var counters = new LoadCounters(); var result = new List <object>(); //string schemaPath = @"..\..\..\nab.QR.FpML.V5r3\" + viewName + ".xsd"; //string schemaFullPath = Path.GetFullPath(schemaPath); //if (!File.Exists(schemaFullPath)) // throw new FileNotFoundException("Schema missing!", schemaFullPath); const string fileSpec = "*.xml"; const string sampleFilesPath = @"..\..\..\..\..\Metadata\FpML.V5r3\fpml.org\samples\5.3\Confirmation\products"; // temp files string incomingFullPath = Path.GetFullPath(@"..\..\step1incoming.xml"); string fullPath = Path.GetFullPath(sampleFilesPath); var filenames = Directory.GetFiles(fullPath, fileSpec, SearchOption.AllDirectories); System.Diagnostics.Debug.Print("Loading {0}", filenames.Length); for (int index = 0; index < filenames.Length; index++) { string originalFilename = filenames[index]; //string baseFilename = Path.GetFileName(originalFilename); //string relativePath = Path.GetDirectoryName(originalFilename.Substring(fullPath.Length)); string testId = String.Format("File{0}", index); //System.Diagnostics.Debug.Print("[{0}] {1} ({2}) processing...", index, baseFilename, relativePath); counters.FilesProcessed.Inc(); // validation //if (validateOriginal) //{ // ValidateXml(testLog, testId, originalFilename, schemaSet, counters.OrigValidationErrors, counters.OrigValidationWarnings); //} // incoming transformation TransformXml(testLog, testId, transformIncomingViaXsl, originalFilename, incomingFullPath, counters.IncomingTransformErrors); // deserialise object fpml = DeserialiseXml(testLog, testId, typeDetector, incomingFullPath, counters.DeserialisationErrors); result.Add(fpml); } return(result); }
public static LoadCounters LoadFiles( string viewName, XmlSchemaSet schemaSet, Func <string, Type> typeDetector, string pattern, IXmlTransformer transformIncomingViaXsl, IXmlTransformer transformOutgoingViaXsl, bool validateOriginal, bool emitAndCompare, bool validateEmitted) { ITestLog testLog = new DebugLog(); var counters = new LoadCounters(); //string schemaPath = @"..\..\..\nab.QR.FpML.V5r3\" + viewName + ".xsd"; //string schemaFullPath = Path.GetFullPath(schemaPath); //if (!File.Exists(schemaFullPath)) // throw new FileNotFoundException("Schema missing!", schemaFullPath); string sampleFilesPath = @"..\..\..\..\..\Metadata\FpML.V5r3\fpml.org\samples\5.3\" + viewName; // temp files string incomingFullPath = Path.GetFullPath(@"..\..\step1incoming.xml"); string internalFullPath = Path.GetFullPath(@"..\..\step2internal.xml"); string outgoingFullPath = Path.GetFullPath(@"..\..\step3outgoing.xml"); string fullPath = Path.GetFullPath(sampleFilesPath); var filenames = Directory.GetFiles(fullPath, pattern, SearchOption.AllDirectories); System.Diagnostics.Debug.Print("Loading {0} files from path: {1}", filenames.Length, fullPath); for (int index = 0; index < filenames.Length; index++) { string originalFilename = filenames[index]; string baseFilename = Path.GetFileName(originalFilename); string relativePath = Path.GetDirectoryName(originalFilename.Substring(fullPath.Length)); string testId = String.Format("File{0}", index); System.Diagnostics.Debug.Print("[{0}] {1} ({2}) processing...", index, baseFilename, relativePath); counters.FilesProcessed.Inc(); // validation if (validateOriginal) { ValidateXml(testLog, testId, originalFilename, schemaSet, counters.OrigValidationErrors, counters.OrigValidationWarnings); } // incoming transformation TransformXml(testLog, testId, transformIncomingViaXsl, originalFilename, incomingFullPath, counters.IncomingTransformErrors); // deserialise object fpml = DeserialiseXml(testLog, testId, typeDetector, incomingFullPath, counters.DeserialisationErrors); // serialise SerialiseXml(testLog, testId, fpml, internalFullPath, counters.SerialisationErrors); // compare internal docuemnts CompareXml(testLog, testId, incomingFullPath, internalFullPath, counters.InternalComparisonErrors); // outgoing transformation TransformXml(testLog, testId, transformOutgoingViaXsl, internalFullPath, outgoingFullPath, counters.OutgoingTransformErrors); // compare external docuemnts if (emitAndCompare) { CompareXml(testLog, testId, originalFilename, outgoingFullPath, counters.ExternalComparisonErrors); } if (validateEmitted) { ValidateXml(testLog, testId, outgoingFullPath, schemaSet, counters.CopyValidationErrors, counters.CopyValidationWarnings); } } return(counters); }