private void RunVersioningTests(SifVersion dataVersion, SifVersion schemaVersion, bool ignoreEnumerationErrors)
        {
            // Tests assume that the schema files are embedded in the test assembly
            DirectoryInfo workingDirectory  = new DirectoryInfo(Environment.CurrentDirectory);
            Type          rootNamespaceType = typeof(UsAdkTest);

            String schemaVersionStr      = getShortenedVersion(schemaVersion);
            String schemaResourcePath    = rootNamespaceType.Namespace + ".schemas." + schemaVersionStr;
            AssemblyResourceResolver asr = new AssemblyResourceResolver(rootNamespaceType.Assembly, schemaResourcePath);

            SchemaValidator sv = null;

            using (Stream rootSchema = rootNamespaceType.Assembly.GetManifestResourceStream(schemaResourcePath + ".SIF_Message.xsd"))
                using (TextReader textReader = new StreamReader(rootSchema))
                {
                    sv = SchemaValidator.NewInstance(textReader, asr);
                    textReader.Close();
                    rootSchema.Close();
                }

            sv.IgnoreEnumerationErrors = ignoreEnumerationErrors;

            String dataVersionStr = getShortenedVersion(dataVersion);

            // Warning, slight hack. Move up two directories to the project root directory (assumes the project directory is still there)
            workingDirectory = workingDirectory.Parent.Parent;
            DirectoryInfo dataDir = new DirectoryInfo(workingDirectory.FullName + "\\data\\" + dataVersionStr);

            int errorCount = RunDirectoryTest(dataVersion, schemaVersion, dataDir, Console.Out, sv);

            Assert.AreEqual(0, errorCount, "Tests Failed. See System.out for details");
        }
        private void RunVersioningTests(SifVersion dataVersion, SifVersion testVersion, bool ignoreEnumerationErrors)
        {
            // Tests assume a working directory that has the schemas in subfolders
            DirectoryInfo workingDirectory = new DirectoryInfo(Environment.CurrentDirectory);
            String        testVersionStr   = getShortenedVersion(testVersion);

            SchemaValidator sv = SchemaValidator.NewInstance(workingDirectory.FullName + "\\schemas\\" + testVersionStr + "\\SIF_Message.xsd");

            sv.IgnoreEnumerationErrors = ignoreEnumerationErrors;

            String        dataVersionStr = getShortenedVersion(dataVersion);
            DirectoryInfo dataDir        = new DirectoryInfo(workingDirectory.FullName + "\\data\\" + dataVersionStr);

            int errorCount = RunDirectoryTest(dataVersion, testVersion, dataDir, Console.Out, sv);

            Assert.AreEqual(0, errorCount, "Tests Failed. See System.out for details");
        }
Beispiel #3
0
        public static SchemaValidator NewInstance(SifVersion schemaVersion)
        {
            Type   rootNamespaceType  = typeof(UsAdkTest);
            String schemaVersionStr   = getShortenedVersion(schemaVersion);
            String schemaResourcePath = rootNamespaceType.Namespace + ".schemas." + schemaVersionStr;

            AssemblyResourceResolver asr = new AssemblyResourceResolver(rootNamespaceType.Assembly, schemaResourcePath);

            SchemaValidator sv = null;

            using (Stream rootSchema = rootNamespaceType.Assembly.GetManifestResourceStream(schemaResourcePath + ".SIF_Message.xsd"))
                using (TextReader textReader = new StreamReader(rootSchema))
                {
                    sv = SchemaValidator.NewInstance(textReader, asr);
                    textReader.Close();
                    rootSchema.Close();
                }

            return(sv);
        }