public void HeaderSystemTests()
        {
            IReader reader = new FileReader(@".\Resources\DataDictionary\datadict.rpt");

            IModelParser[] parsers = new IModelParser[] {
                new PageHeaderParser(),
                new AccessInformationParser(),
                new DescriptionParser(),
                new DetailsParser(),
                new ModifiedParser(),
                new ModuleParser(),
                new RecordLengthParser(),
                new RecordParser(),
                new TechnicalInformationParser(),
                CobolParser.CobolHierarchy(),
                new IgnoreParser(),
            };
            IDataParser dataParser = new DataParser(reader, parsers);

            dataParser.Corrections     = corrections;
            dataParser.OnMissingParser = (line) =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();
        }
        public void ParseMSF005_RECORD()
        {
            FileReader  reader     = new FileReader(@".\Resources\Cobol\MSF005-RECORD.rpt");
            IDataParser dataParser = CreateDataParser(reader, CobolParser.CobolHierarchy());

            dataParser.Corrections     = null;
            dataParser.OnMissingParser = line =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();
            IModel expected =
                Build.Class("MSF005-RECORD")
                .With(
                    Build.Property("KEY-005", "comment")
                    .WithDataType("DSTRCT-CODE PIC X(4)", "comment")
                    .WithDataType("USER-TYPE PIC X(2)", "comment")
                    .WithDataType("TLX-SEQ-NO PIC X(12)", "comment")
                    .With(
                        Build.Property("LINE-NO", "comment")
                        .WithDataType("LINE-NO-9 PIC 9(4)", "comment")
                        )
                    )
                .WithDataType("TLX-TEXT PIC X(72)", "comment")
                .Model();

            AssertParsedUsingToString(dataParser, expected);
        }
        public void ParseMSF004_RECORD()
        {
            FileReader  reader     = new FileReader(@".\Resources\Cobol\MSF004-RECORD.rpt");
            IDataParser dataParser = CreateDataParser(reader, CobolParser.CobolHierarchy());

            dataParser.Corrections     = null;
            dataParser.OnMissingParser = line =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();

            IModel expected =
                Build.Class("MSF004-RECORD")
                .With(
                    Build.Property("KEY-004", "comment")
                    .WithDataType("DSTRCT-CODE PIC X(4)", "comment")
                    .WithDataType("FULL-PERIOD PIC X(6)", "comment")
                    )
                .With(
                    Build.Property("END-DATE", "comment")
                    .WithDataType("END-DATE-9 PIC 9(8)", "comment")
                    )
                .With(
                    Build.Property("GAP-END-DATE", "comment")
                    .WithDataType("GAP-END-DATE-9 PIC 9(8)", "comment")
                    )
                .WithDataType("TAX-PERIOD-CLOSED PIC X(1)", "comment")
                .Model();

            AssertParsedUsingToString(dataParser, expected);
        }
        public void ParseMSF003_RECORD()
        {
            FileReader  reader     = new FileReader(@".\Resources\Cobol\MSF003-RECORD.rpt");
            IDataParser dataParser = CreateDataParser(reader, CobolParser.CobolHierarchy());

            dataParser.Corrections     = null;
            dataParser.OnMissingParser = line =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();

            IModel expected =
                Build.Class("MSF003-RECORD")
                .With(
                    Build.Property("KEY-003", "[ 1] key 003 FK:0")
                    .WithDataType("ATTR-NAME-LONG PIC X(64)", "[ 1] Long Attribute Name DB,KEY:0")
                    )
                .With(
                    Build.Property("AIX1-KEY-003", "[ 65] Alternative key for short Attribute Name FK:1")
                    .WithDataType("ATTR-NAME-SHRT PIC X(14)", "[ 65] Short Attribute Name DB,KEY:1")
                    )
                .WithDataType("AGE-METHOD PIC X(2)", "[ 79] Ageing Method DB")
                .Model();

            AssertParsedUsingXml(dataParser, expected);
        }
        public void ParseMSW000_RECORD()
        {
            FileReader  reader     = new FileReader(@".\Resources\Cobol\MSW000-RECORD.rpt");
            IDataParser dataParser = CreateDataParser(reader, CobolParser.CobolHierarchy(), new IgnoreParser());

            dataParser.Corrections     = null;
            dataParser.OnMissingParser = line =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();
            IModel expected =
                Build.Class("MSW000-RECORD")
                .With(
                    Build.Property("KEY-W000", "comment")
                    .WithDataType("USERNO PIC X(4)", "comment")
                    .WithDataType("W000-KEY PIC X(10)", "comment")
                    )
                .With(
                    Build.DataType("W000-FILE-FLAGS PIC X(1)", "comment")
                    )
                .With(
                    Build.Property("W000-FILE-DATA", "comment")
                    .With(
                        Build.Property("W000-DATA-REC", "comment")
                        .With(
                            Build.Property("W000-DATA-GRP", "comment")
                            .WithDataType("W000-DATA-1 PIC X(95)", "comment")
                            .WithDataType("W000-DATA-2 PIC X(95)", "comment")
                            .WithDataType("W000-DATA-3 PIC X(95)", "comment")
                            )
                        .With(
                            Build.Redefines("W000-DATA-RT REDEFINES W000-DATA-GRP", "comment")
                            .With(
                                Build.Property("W000-REDEF-REC", "comment")
                                .With(Build.Occurs(
                                          "W000-DATA OCCURS 3 INDEXED BY W000-DATA-IDX",
                                          "comment")
                                      .With(Build.DataType("PIC X(95)", "Implied"))
                                      )
                                )
                            )
                        )
                    )
                .WithDataType("FILLER PIC X(4)")
                .Model();

            AssertParsedUsingToString(dataParser, expected);
        }
        public void HierarchySystemTests()
        {
            IReader reader = new FileReader(@".\Resources\DataDictionary\datadict.rpt");

            IModelParser[] parsers = new IModelParser[] {
                new AccessInformationParser(),
                new DescriptionParser(),
                new DetailsParser(),
                new ModifiedParser(),
                new ModuleParser(),
                new PageHeaderParser(),
                new RecordLengthParser(),
                new RecordParser(),
                new TechnicalInformationParser(),
                CobolParser.CobolHierarchy(),
                new IgnoreParser(),
            };
            IDataParser dataParser = new DataParser(reader, parsers);

            dataParser.Corrections     = corrections;
            dataParser.OnMissingParser = (line) =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();

            string typename  = GetType().Name;
            string directory = Path.Combine(".", typename);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            foreach (IModel model in dataParser.Results)
            {
                HierarchyModel hiearchyModel = model as HierarchyModel;
                if (hiearchyModel != null)
                {
                    ClassModel classModel = hiearchyModel.Model as ClassModel;
                    if (classModel != null)
                    {
                        ModelXmlFormatter formatter  = new ModelXmlFormatter(model);
                        string            xml        = formatter.Render();
                        string            objectName = classModel.Data;

                        string fileName = directory + @"\" + objectName + ".xml";
                        if (File.Exists(fileName))
                        {
                            File.Delete(fileName);
                        }

                        Assert.That(File.Exists(fileName), Is.False);
                        using (StreamWriter writer = new StreamWriter(fileName))
                        {
                            writer.Write(xml);
                        }
                    }
                }
            }
        }
        public void ParseMSF006_RECORD()
        {
            FileReader  reader     = new FileReader(@".\Resources\Cobol\MSF006-RECORD.rpt");
            IDataParser dataParser = CreateDataParser(reader, CobolParser.CobolHierarchy());

            dataParser.Corrections     = null;
            dataParser.OnMissingParser = line =>
            {
                throw new InvalidOperationException("No Parser for: " + reader);
            };
            dataParser.Parse();

            IModel expected = Build
                              .Class("MSF006-RECORD")
                              .With(
                Build.Property("KEY-006", "comment")
                .WithDataType("DSTRCT-CODE PIC X(4)", "comment")
                .WithDataType("ACCOUNT-CODE PIC X(24)", "comment")
                .With(
                    Build.Property("CONTROL-ID", "comment")
                    .With(
                        Build.DataType("CONTROL-TYPE PIC X(1)", "comment")
                        .WithValue("MIMS-CONTROL VALUE 'M'", "comment")
                        .WithValue("INTER-DSTRCT-CTL VALUE 'I'", "comment")
                        .WithValue("SUBLEDGER-CTL VALUE 'S'", "comment")
                        .WithValue("TABLE-DSTRCT-CTL VALUE 'T'", "comment")
                        )
                    .With(
                        Build.Property("CONTROL-NUMBER", "comment")
                        .With(
                            Build.Property("INT-DSTRCT", "comment")
                            .WithDataType("SUBLEDGER-TYPE PIC X(2)", "comment")
                            .WithDataType("FILLER PIC X(2)")
                            )
                        )
                    )
                .With(
                    Build.DataType("INVENT-CAT PIC X(2)", "comment")
                    )
                )
                              .With(
                Build.Property("AIX1-KEY-006", "comment")
                .WithDataType("DSTRCT-CODE-2 PIC X(4)", "comment")
                .WithDataType("CONTROL-ID-2 PIC X(5)", "comment")
                .WithDataType("INVENT-CAT-2 PIC X(2)", "comment")
                .WithDataType("ACCOUNT-CODE-2 PIC X(24)", "comment")
                )
                              .With(
                Build.DataType("SL-ACCT-TY-IND PIC X(2)", "comment")
                .WithValue("PO-NO-ITEM VALUE 'PO'", "comment")
                .WithValue("INVOICE-NUM VALUE 'IN'", "comment")
                )
                              .With(
                Build.DataType("TARGT-ACCT-CDE PIC X(24)", "comment")
                )
                              .With(
                Build.DataType("TARGT-OFF-ACCT PIC X(24)", "comment")
                )
                              .With(
                Build.DataType("TARGT-AUTO-SW PIC X(1)", "comment")
                .WithValue("TARGT-AUTOGEN VALUE 'Y'", "comment")
                .WithValue("TARGT-NO-AUTOGEN VALUE 'N'", "comment")
                )
                              .With(
                Build.DataType("TARGT-OFF-SW PIC X(1)", "comment")
                .WithValue("TARGT-OFF-DIST VALUE 'Y'", "comment")
                .WithValue("TARGT-NO-OFF-DIST VALUE 'N'", "comment")
                )
                              .Model();

            AssertParsedUsingToString(dataParser, expected);
        }