Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="viewName"></param>
        /// <param name="schemaSet"></param>
        /// <param name="typeDetector"></param>
        /// <param name="pattern"></param>
        /// <param name="transformIncomingViaXsl"></param>
        /// <param name="transformOutgoingViaXsl"></param>
        /// <param name="validateOriginal"></param>
        /// <param name="emitAndCompare"></param>
        /// <param name="validateEmitted"></param>
        /// <returns></returns>
        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   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           = $"File{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 documents
                CompareXml(testLog, testId, incomingFullPath, internalFullPath, counters.InternalComparisonErrors);
                // outgoing transformation
                TransformXml(testLog, testId, transformOutgoingViaXsl, internalFullPath, outgoingFullPath, counters.OutgoingTransformErrors);
                // compare external documents
                if (emitAndCompare)
                {
                    CompareXml(testLog, testId, originalFilename, outgoingFullPath, counters.ExternalComparisonErrors);
                }
                if (validateEmitted)
                {
                    ValidateXml(testLog, testId, outgoingFullPath, schemaSet, counters.CopyValidationErrors, counters.CopyValidationWarnings);
                }
            }
            return(counters);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="schemaSet"></param>
        /// <param name="typeDetector"></param>
        /// <param name="transformIncomingViaXsl"></param>
        /// <param name="transformOutgoingViaXsl"></param>
        /// <param name="validateOriginal"></param>
        /// <param name="emitAndCompare"></param>
        /// <param name="validateEmitted"></param>
        /// <returns></returns>
        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 = $"File{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);
        }