コード例 #1
0
        public void ClassWithProperty()
        {
            IModel model = Build.Class("Class001").WithProperty("PROP001", "Comment").Model();
            ModelXmlFormatter formatter = new ModelXmlFormatter(model);

            AssertXmlIsSame(formatter.Render(), "<Class name='Class001' text='Class001' path='1'>" +
                                                "  <Property name='PROP001' text='PROP001' comment='Comment' path='1.1'/>" +
                                                "</Class>");
        }
コード例 #2
0
        public void ClassWithProperty()
        {
            IModel            model     = Build.Class("Class001").WithProperty("PROP001", "Comment").Model();
            ModelXmlFormatter formatter = new ModelXmlFormatter(model);

            AssertXmlIsSame(formatter.Render(), "<Class name='Class001' text='Class001' path='1'>" +
                            "  <Property name='PROP001' text='PROP001' comment='Comment' path='1.1'/>" +
                            "</Class>");
        }
コード例 #3
0
 public HierarchyModel(IModel model, IModel[] childModels)
 {
     if (model is HierarchyModel)
     {
         string xml = new ModelXmlFormatter(model).Render();
         throw new InvalidOperationException("Invalid Model \r\n" + xml);
     }
     Model       = model;
     ChildModels = childModels;
 }
コード例 #4
0
 public HierarchyModel(IModel model, IModel[] childModels)
 {
     if (model is HierarchyModel)
     {
         string xml = new ModelXmlFormatter(model).Render();
         throw new InvalidOperationException("Invalid Model \r\n" + xml);
     }
     Model = model;
     ChildModels = childModels;
 }
コード例 #5
0
        public void ClassWith2BranchesOfPropertiesWithPath()
        {
            IModel model = Build
                .Class("Class001").With(
                    Build.Property("PROP00A", "Comment").WithProperty("PROP0A1", "Comment").WithProperty("PROP0A2", "Comment")
                )
                .With(
                    Build.Property("PROP00B", "Comment").WithProperty("PROP0B1", "Comment").WithProperty("PROP0B2", "Comment")
                ).Model();
            ModelXmlFormatter formatter = new ModelXmlFormatter(model);

            const string expected = "<Class name='Class001' text='Class001' path='1'>" +
                                    "  <Property name='PROP00A' text='PROP00A' comment='Comment' path='1.1'>" +
                                    "    <Property name='PROP0A1' text='PROP0A1' comment='Comment' path='1.1.1' />" +
                                    "    <Property name='PROP0A2' text='PROP0A2' comment='Comment' path='1.1.2' />" +
                                    "  </Property>" +
                                    "  <Property name='PROP00B' text='PROP00B' comment='Comment' path='1.2'>" +
                                    "    <Property name='PROP0B1' text='PROP0B1' comment='Comment' path='1.2.1' />" +
                                    "    <Property name='PROP0B2' text='PROP0B2' comment='Comment' path='1.2.2' />" +
                                    "  </Property>" +
                                    "</Class>";

            AssertXmlIsSame(formatter.Render(), expected);
        }
コード例 #6
0
        public void ClassWith2BranchesOfPropertiesWithPath()
        {
            IModel model = Build
                           .Class("Class001").With(
                Build.Property("PROP00A", "Comment").WithProperty("PROP0A1", "Comment").WithProperty("PROP0A2", "Comment")
                )
                           .With(
                Build.Property("PROP00B", "Comment").WithProperty("PROP0B1", "Comment").WithProperty("PROP0B2", "Comment")
                ).Model();
            ModelXmlFormatter formatter = new ModelXmlFormatter(model);

            const string expected = "<Class name='Class001' text='Class001' path='1'>" +
                                    "  <Property name='PROP00A' text='PROP00A' comment='Comment' path='1.1'>" +
                                    "    <Property name='PROP0A1' text='PROP0A1' comment='Comment' path='1.1.1' />" +
                                    "    <Property name='PROP0A2' text='PROP0A2' comment='Comment' path='1.1.2' />" +
                                    "  </Property>" +
                                    "  <Property name='PROP00B' text='PROP00B' comment='Comment' path='1.2'>" +
                                    "    <Property name='PROP0B1' text='PROP0B1' comment='Comment' path='1.2.1' />" +
                                    "    <Property name='PROP0B2' text='PROP0B2' comment='Comment' path='1.2.2' />" +
                                    "  </Property>" +
                                    "</Class>";

            AssertXmlIsSame(formatter.Render(), expected);
        }
コード例 #7
0
        public void StringModel()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new StringModel("Name", "Data"));

            AssertXmlIsSame(formatter.Render(), "<Name data='Data' path='1' />");
        }
コード例 #8
0
        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);
                        }
                    }
                }
            }
        }
コード例 #9
0
        public void PageHeader()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new PageHeaderModel(new[] { "One", "Two", "Three" }));

            AssertXmlIsSame(formatter.Render(), "<Page lines='One\r\nTwo\r\nThree' path='1'/>");
        }
コード例 #10
0
        public void PageHeader()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new PageHeaderModel(new[] { "One", "Two", "Three" }));

            AssertXmlIsSame(formatter.Render(), "<Page lines='One\r\nTwo\r\nThree' path='1'/>");
        }
コード例 #11
0
        public void DataTypeModel()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(Models.DataTypeModel.Factory("DataType", "NAME-01 PIC X(1)", null));

            AssertXmlIsSame(formatter.Render(), "<DataType name='NAME-01' type='X(1)' text='NAME-01 PIC X(1)' path='1' />");
        }
コード例 #12
0
        public void IgnoreModel()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new IgnoreModel("This is some data"));

            AssertXmlIsSame(formatter.Render(), "<Ignore line='This is some data' path='1' />");
        }
コード例 #13
0
        public void CobolModelWithComment()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new CobolModel("Name", "Data", "Comment"));

            AssertXmlIsSame(formatter.Render(), "<Name data='Data' comment='Comment' path='1' />");
        }
コード例 #14
0
        public void CobolModel()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new CobolModel("Name", "Data"));

            AssertXmlIsSame(formatter.Render(), "<Name data='Data' path='1' />");
        }
コード例 #15
0
        public void IgnoreModel()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new IgnoreModel("This is some data"));

            AssertXmlIsSame(formatter.Render(), "<Ignore line='This is some data' path='1' />");
        }
コード例 #16
0
        public void DataTypeModel()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(Models.DataTypeModel.Factory("DataType", "NAME-01 PIC X(1)", null));

            AssertXmlIsSame(formatter.Render(), "<DataType name='NAME-01' type='X(1)' text='NAME-01 PIC X(1)' path='1' />");
        }
コード例 #17
0
        public void CobolModelWithComment()
        {
            ModelXmlFormatter formatter = new ModelXmlFormatter(new CobolModel("Name", "Data", "Comment"));

            AssertXmlIsSame(formatter.Render(), "<Name data='Data' comment='Comment' path='1' />");
        }