Пример #1
0
        private FlatFile GetDokDat()
        {
            var       workingDirectory = new WorkingDirectory(ArkadeProcessingArea.WorkDirectory, new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/TestData/noark3"));
            AddmlInfo addml            = AddmlUtil.ReadFromFile(workingDirectory.Content().WithFile("noark_3_arkivuttrekk_med_prosesser.xml").FullName);

            AddmlDefinition addmlDefinition = new AddmlDefinitionParser(addml, workingDirectory, new StatusEventHandler()).GetAddmlDefinition();
            FlatFile        flatFile        = addmlDefinition.GetFlatFiles().Single(file => file.Definition.FileName == "DOK.DAT");

            return(flatFile);
        }
Пример #2
0
        private FlatFile GetDokDat()
        {
            var       workingDirectory = new WorkingDirectory(ArkadeConstants.GetArkadeWorkDirectory(), new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestData\\noark3\\"));
            AddmlInfo addml            = AddmlUtil.ReadFromFile(workingDirectory.Content().WithFile("noark_3_arkivuttrekk_med_prosesser.xml").FullName);

            AddmlDefinition addmlDefinition = new AddmlDefinitionParser(addml, workingDirectory, new StatusEventHandler()).GetAddmlDefinition();
            FlatFile        flatFile        = addmlDefinition.GetFlatFiles().Single(file => file.Definition.FileName == "DOK.DAT");

            return(flatFile);
        }
Пример #3
0
        public void ShouldReturnTestSuiteFromTests()
        {
            var             workingDirectory = new WorkingDirectory(ArkadeConstants.GetArkadeWorkDirectory(), new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestData\\noark3\\"));
            AddmlInfo       addml            = AddmlUtil.ReadFromFile(workingDirectory.Root().WithFile("noark_3_arkivuttrekk_med_prosesser.xml").FullName);
            AddmlDefinition addmlDefinition  = new AddmlDefinitionParser(addml, workingDirectory).GetAddmlDefinition();

            var testSession = new TestSession(new Archive(ArchiveType.Noark3, Uuid.Random(), workingDirectory));

            testSession.AddmlDefinition = addmlDefinition;

            var       addmlDatasetTestEngine = new AddmlDatasetTestEngine(new FlatFileReaderFactory(), new AddmlProcessRunner(), new StatusEventHandler());
            TestSuite testSuite = addmlDatasetTestEngine.RunTestsOnArchive(testSession);


            testSuite.Should().NotBeNull();
            testSuite.TestRuns.Should().NotBeNullOrEmpty();

            List <TestRun> analyseFindMinMaxValues = testSuite.TestRuns
                                                     .Where(run => run.TestName == AnalyseFindMinMaxValues.Name)
                                                     .ToList();

            analyseFindMinMaxValues.Count.Should().Be(1);
        }
Пример #4
0
        public void ShouldParseNoark4ConvertedArkivuttrekkXml()
        {
            // Code to convert NOARKIH.XML to addml.xml
            //string noarkihString = TestUtil.ReadFromFileInTestDataDir("noark4\\NOARKIH.XML");
            //string addmlString = NoarkihToAddmlTransformer.Transform(noarkihString);

            // File is converted from NOARKIH.XML format

            var testDataDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\TestData\\noark4");
            var workingDirectory  = new WorkingDirectory(testDataDirectory, testDataDirectory);

            AddmlInfo addml = AddmlUtil.ReadFromFile(workingDirectory.Content().WithFile("addml.xml").FullName);

            AddmlDefinitionParser parser = new AddmlDefinitionParser(addml, workingDirectory, new StatusEventHandler());

            AddmlDefinition addmlDefinition = parser.GetAddmlDefinition();

            List <AddmlFlatFileDefinition> addmlFlatFileDefinitions = addmlDefinition.AddmlFlatFileDefinitions;

            addmlFlatFileDefinitions.Count.Should().Be(63);
            addmlFlatFileDefinitions[0].Name.Should().Be("ORDNPRINSTYPE");
            addmlFlatFileDefinitions[0].FileName.Should().Be("OPRITYP.XML");
            addmlFlatFileDefinitions[0].Encoding.Should().Be(Encodings.ISO_8859_1);
            addmlFlatFileDefinitions[0].RecordSeparator.Should().BeNull();
            addmlFlatFileDefinitions[0].AddmlRecordDefinitions.Count.Should().Be(1);
            AddmlRecordDefinition addmlRecordDefinition = addmlFlatFileDefinitions[0].AddmlRecordDefinitions[0];

            addmlRecordDefinition.Name.Should().Be("ORDNPRINSTYPE");
            List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;

            addmlFieldDefinitions.Count.Should().Be(2);
            addmlFieldDefinitions[0].Name.Should().Be("OT.KODE");
            addmlFieldDefinitions[0].Type.Should().Be(StringDataType.Default);
            addmlFieldDefinitions[1].Name.Should().Be("OT.BETEGN");
            addmlFieldDefinitions[1].Type.Should().Be(StringDataType.Default);
            addmlRecordDefinition.PrimaryKey.Should().BeNull();
        }
Пример #5
0
        public void ShouldParseJegerreg98ArkivuttrekkXml()
        {
            var       externalContentDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestData\\jegerreg-98-dos\\");
            var       workingDirectory         = new WorkingDirectory(ArkadeConstants.GetArkadeWorkDirectory(), externalContentDirectory);
            AddmlInfo addml = AddmlUtil.ReadFromFile(workingDirectory.Content().WithFile("arkivuttrekk.xml").FullName);

            AddmlDefinition addmlDefinition = new AddmlDefinitionParser(addml, workingDirectory).GetAddmlDefinition();

            List <AddmlFlatFileDefinition> addmlFlatFileDefinitions = addmlDefinition.AddmlFlatFileDefinitions;

            addmlFlatFileDefinitions.Count.Should().Be(10);
            {
                addmlFlatFileDefinitions[0].Name.Should().Be("ffd_3");
                addmlFlatFileDefinitions[0].FileName.Should().Be("jeger.dat");
                addmlFlatFileDefinitions[0].Encoding.Should().Be(Encodings.ISO_8859_1);
                addmlFlatFileDefinitions[0].RecordSeparator.Should().Be(Separator.CRLF);
                addmlFlatFileDefinitions[0].AddmlRecordDefinitions.Count.Should().Be(1);
                AddmlRecordDefinition       addmlRecordDefinition = addmlFlatFileDefinitions[0].AddmlRecordDefinitions[0];
                List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;
                addmlFieldDefinitions.Count.Should().Be(36);
                addmlFieldDefinitions[0].Name.Should().Be("fodselsnummer");
                addmlRecordDefinition.PrimaryKey.Should()
                .Equal(new List <AddmlFieldDefinition>()
                {
                    addmlFieldDefinitions[0]
                });
            }
            {
                addmlFlatFileDefinitions[1].Name.Should().Be("ffd_4");
                addmlFlatFileDefinitions[1].FileName.Should().Be("ut_jeger.dat");
                addmlFlatFileDefinitions[1].Encoding.Should().Be(Encodings.ISO_8859_1);
                addmlFlatFileDefinitions[1].RecordSeparator.Should().Be(Separator.CRLF);
                addmlFlatFileDefinitions[1].AddmlRecordDefinitions.Count.Should().Be(1);
                AddmlRecordDefinition       addmlRecordDefinition = addmlFlatFileDefinitions[1].AddmlRecordDefinitions[0];
                List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;
                addmlFieldDefinitions.Count.Should().Be(37);
                addmlFieldDefinitions[0].Name.Should().Be("plassnummer");
                addmlFieldDefinitions[0].Type.Should().Be(IntegerDataType.Default);
                addmlFieldDefinitions[1].Name.Should().Be("landkort");
                addmlFieldDefinitions[8].Name.Should().Be("personnummer");
                addmlRecordDefinition.PrimaryKey.Should()
                .Equal(new List <AddmlFieldDefinition>()
                {
                    addmlFieldDefinitions[0],
                    addmlFieldDefinitions[1],
                    addmlFieldDefinitions[8]
                });
            }
            {
                addmlFlatFileDefinitions[2].Name.Should().Be("ffd_5");
                addmlFlatFileDefinitions[2].FileName.Should().Be("ikkejeg.dat");
                addmlFlatFileDefinitions[2].Encoding.Should().Be(Encodings.ISO_8859_1);
                addmlFlatFileDefinitions[2].RecordSeparator.Should().Be(Separator.CRLF);
                addmlFlatFileDefinitions[2].AddmlRecordDefinitions.Count.Should().Be(1);
                AddmlRecordDefinition       addmlRecordDefinition = addmlFlatFileDefinitions[2].AddmlRecordDefinitions[0];
                List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;
                addmlFieldDefinitions.Count.Should().Be(44);
                addmlFieldDefinitions[0].Name.Should().Be("fodselsnummer");
                addmlFieldDefinitions[0].StartPosition.Should().Be(1);
                addmlFieldDefinitions[0].FixedLength.Should().Be(11);
                addmlFieldDefinitions[0].IsUnique.Should().BeTrue();
                addmlFieldDefinitions[0].IsNullable.Should().BeFalse();
                addmlFieldDefinitions[0].MaxLength.Should().NotHaveValue();
                addmlFieldDefinitions[0].MinLength.Should().NotHaveValue();
                addmlFieldDefinitions[0].Type.Should().Be(StringDataType.Default);
                addmlFieldDefinitions[0].ForeignKey.Should().Be(
                    addmlFlatFileDefinitions[0].AddmlRecordDefinitions[0].AddmlFieldDefinitions[0]
                    );

                addmlFieldDefinitions[1].Name.Should().Be("etternavn");
                addmlFieldDefinitions[1].StartPosition.Should().Be(12);
                addmlFieldDefinitions[1].FixedLength.Should().Be(25);
                addmlFieldDefinitions[1].IsUnique.Should().BeFalse();
                addmlFieldDefinitions[1].IsNullable.Should().BeTrue();
                addmlFieldDefinitions[1].MaxLength.Should().NotHaveValue();
                addmlFieldDefinitions[1].MinLength.Should().NotHaveValue();
                addmlFieldDefinitions[1].Type.Should().Be(StringDataType.Default);
                addmlFieldDefinitions[1].ForeignKey.Should().BeNull();

                addmlRecordDefinition.PrimaryKey.Should()
                .Equal(new List <AddmlFieldDefinition>()
                {
                    addmlFieldDefinitions[0]
                });


                TestDateDataType(addmlDefinition);
                TestBooleanDataType(addmlDefinition);
                TestFloatDataType(addmlDefinition);
            }
        }
Пример #6
0
        public void ShouldParseJegerreg98ArkivuttrekkXml()
        {
            var       externalContentDirectory = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\TestData\\jegerreg-98-dos");
            var       workingDirectory         = new WorkingDirectory(ArkadeProcessingArea.WorkDirectory, externalContentDirectory);
            AddmlInfo addml = AddmlUtil.ReadFromFile(workingDirectory.Content().WithFile("arkivuttrekk.xml").FullName);

            AddmlDefinition addmlDefinition = new AddmlDefinitionParser(addml, workingDirectory, new StatusEventHandler()).GetAddmlDefinition();

            List <AddmlFlatFileDefinition> addmlFlatFileDefinitions = addmlDefinition.AddmlFlatFileDefinitions;

            addmlFlatFileDefinitions.Count.Should().Be(10);
            {
                addmlFlatFileDefinitions[0].Name.Should().Be("ffd_3");
                addmlFlatFileDefinitions[0].FileName.Should().Be("jeger.dat");
                addmlFlatFileDefinitions[0].Encoding.Should().Be(Encodings.ISO_8859_1);
                addmlFlatFileDefinitions[0].RecordSeparator.Should().Be(Separator.CRLF);
                addmlFlatFileDefinitions[0].AddmlRecordDefinitions.Count.Should().Be(1);
                AddmlRecordDefinition       addmlRecordDefinition = addmlFlatFileDefinitions[0].AddmlRecordDefinitions[0];
                List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;
                addmlFieldDefinitions.Count.Should().Be(36);
                addmlFieldDefinitions[0].Name.Should().Be("fodselsnummer");
                addmlRecordDefinition.PrimaryKey.Should()
                .Equal(new List <AddmlFieldDefinition>()
                {
                    addmlFieldDefinitions[0]
                });
            }
            {
                addmlFlatFileDefinitions[1].Name.Should().Be("ffd_4");
                addmlFlatFileDefinitions[1].FileName.Should().Be("ut_jeger.dat");
                addmlFlatFileDefinitions[1].Encoding.Should().Be(Encodings.ISO_8859_1);
                addmlFlatFileDefinitions[1].RecordSeparator.Should().Be(Separator.CRLF);
                addmlFlatFileDefinitions[1].AddmlRecordDefinitions.Count.Should().Be(1);
                AddmlRecordDefinition       addmlRecordDefinition = addmlFlatFileDefinitions[1].AddmlRecordDefinitions[0];
                List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;
                addmlFieldDefinitions.Count.Should().Be(37);
                addmlFieldDefinitions[0].Name.Should().Be("plassnummer");
                addmlFieldDefinitions[0].Type.Should().Be(IntegerDataType.Default);
                addmlFieldDefinitions[1].Name.Should().Be("landkort");
                addmlFieldDefinitions[8].Name.Should().Be("personnummer");
                addmlRecordDefinition.PrimaryKey.Should()
                .Equal(new List <AddmlFieldDefinition>()
                {
                    addmlFieldDefinitions[0],
                    addmlFieldDefinitions[1],
                    addmlFieldDefinitions[8]
                });
            }
            {
                addmlFlatFileDefinitions[2].Name.Should().Be("ffd_5");
                addmlFlatFileDefinitions[2].FileName.Should().Be("ikkejeg.dat");
                addmlFlatFileDefinitions[2].Encoding.Should().Be(Encodings.ISO_8859_1);
                addmlFlatFileDefinitions[2].RecordSeparator.Should().Be(Separator.CRLF);
                addmlFlatFileDefinitions[2].AddmlRecordDefinitions.Count.Should().Be(1);
                AddmlRecordDefinition       addmlRecordDefinition = addmlFlatFileDefinitions[2].AddmlRecordDefinitions[0];
                List <AddmlFieldDefinition> addmlFieldDefinitions = addmlRecordDefinition.AddmlFieldDefinitions;
                addmlFieldDefinitions.Count.Should().Be(44);
                addmlFieldDefinitions[0].Name.Should().Be("fodselsnummer");
                addmlFieldDefinitions[0].StartPosition.Should().Be(1);
                addmlFieldDefinitions[0].FixedLength.Should().Be(11);
                addmlFieldDefinitions[0].IsUnique.Should().BeTrue();
                addmlFieldDefinitions[0].IsNullable.Should().BeFalse();
                addmlFieldDefinitions[0].MaxLength.Should().NotHaveValue();
                addmlFieldDefinitions[0].MinLength.Should().NotHaveValue();
                addmlFieldDefinitions[0].Type.Should().Be(StringDataType.Default);

                /*              addmlFieldDefinitions[0].ForeignKeys.First().Should().Be(
                 *                addmlFlatFileDefinitions[0].AddmlRecordDefinitions[0].AddmlFieldDefinitions[0]
                 *            );*/

                addmlFieldDefinitions[1].Name.Should().Be("etternavn");
                addmlFieldDefinitions[1].StartPosition.Should().Be(12);
                addmlFieldDefinitions[1].FixedLength.Should().Be(25);
                addmlFieldDefinitions[1].IsUnique.Should().BeFalse();
                addmlFieldDefinitions[1].IsNullable.Should().BeTrue();
                addmlFieldDefinitions[1].MaxLength.Should().NotHaveValue();
                addmlFieldDefinitions[1].MinLength.Should().NotHaveValue();
                addmlFieldDefinitions[1].Type.Should().Be(StringDataType.Default);
//                addmlFieldDefinitions[1].ForeignKeys.Should().BeEmpty();

                addmlRecordDefinition.PrimaryKey.Should()
                .Equal(new List <AddmlFieldDefinition>()
                {
                    addmlFieldDefinitions[0]
                });


                TestDateDataType(addmlDefinition);
                TestBooleanDataType(addmlDefinition);
                TestFloatDataType(addmlDefinition);
            }
        }