Example #1
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();
            ModelFormatter formatter = new ModelFormatter(model)
            {
                IncludeModelPaths = true
            };

            const string expected = "1: [Class] Class001\r\n" +
                                    "1.1: [Property] PROP00A /*...*/\r\n" +
                                    "1.1.1: [Property] PROP0A1 /*...*/\r\n" +
                                    "1.1.2: [Property] PROP0A2 /*...*/\r\n" +
                                    "1.2: [Property] PROP00B /*...*/\r\n" +
                                    "1.2.1: [Property] PROP0B1 /*...*/\r\n" +
                                    "1.2.2: [Property] PROP0B2 /*...*/" +
                                    "";

            Assert.That(formatter.Render(), Is.EqualTo(expected));
        }
Example #2
0
        public void ClassWith2DeepProperties()
        {
            IModel model = Build.Class("Class001")
                           .With(Build.Property("PROP001", "Comment")
                                 .WithProperty("PROP002", "Comment"))
                           .Model();
            ModelFormatter formatter = new ModelFormatter(model);

            Assert.That(formatter.Render(), Is.EqualTo("[Class] Class001\r\n  [Property] PROP001 /*...*/\r\n    [Property] PROP002 /*...*/"));
        }
        public void BuildClassWithProperty()
        {
            IModel model = Build
                           .Class("MSF001")
                           .With(
                Build.Property("PROP001")
                )
                           .Model();

            AssertCobolModel(model, "1", "Class", "MSF001");
            AssertCobolModel(model, "1.1", "Property", "PROP001");
        }
        public void SameModelConstructed()
        {
            IModel simpleModel = 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")
                        )
                    )

                ).Model();

            IModel verboseModel = Build
                                  .Class("MSF006-RECORD")
                                  .With(
                Build.Property("KEY-006", "comment")
                .With(Build.DataType("DSTRCT-CODE PIC X(4)", "comment"))
                .With(Build.DataType("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")
                        )
                    )

                ).Model();

            string simple = new ModelFormatter(simpleModel)
            {
                IncludeModelPaths = true
            }.Render();
            string verbose = new ModelFormatter(verboseModel)
            {
                IncludeModelPaths = true
            }.Render();

            Assert.That(simple, Is.EqualTo(verbose));
        }
        public void ClassWith2DeepProperties()
        {
            IModel model = Build.Class("Class001")
                           .With(Build.Property("PROP001", "Comment")
                                 .WithProperty("PROP002", "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'>" +
                            "    <Property name='PROP002' text='PROP002' comment='Comment' path='1.1.1' />" +
                            "  </Property>" +
                            "</Class>");
        }
        public void BuildClassWithPropertyAndDataType()
        {
            IModel model = Build
                           .Class("MSF001")
                           .With(
                Build.Property("PROP001")
                .With(
                    Build.DataType("DATATYPE001")
                    )
                )
                           .Model();

            AssertCobolModel(model, "1", "Class", "MSF001");
            AssertCobolModel(model, "1.1", "Property", "PROP001");
            AssertCobolModel(model, "1.1.1", "DataType", "DATATYPE001");
        }
        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);
        }