public void GetModelRoot()
        {
            HierarchyModel model  = new HierarchyModel(new CobolModel("Class", "CLASS001"));
            IModel         result = model.GetModel("");

            Assert.That(result, Is.EqualTo(model.Model));
        }
        public void ModelToString()
        {
            HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"));
            Assert.That(model.ToString(), Is.EqualTo(model.Model.ToString()));

            Assert.That(model.ToString(), Is.StringContaining("Class"));
            Assert.That(model.ToString(), Is.StringContaining("CLASS001"));
        }
 public void GetModel11()
 {
     HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"), new IModel[] { new CobolModel("Property", "PROP001"), });
     Assert.That(model.GetModel("1"), Is.EqualTo(model.Model));
     Assert.That(model.GetModel("1.0"), Is.EqualTo(null));
     Assert.That(model.GetModel("1.1"), Is.EqualTo(model.ChildModels[0]));
     Assert.That(model.GetModel("1.2"), Is.EqualTo(null));
 }
 public void GetModel1()
 {
     HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"));
     IModel result = model.GetModel("1");
     Assert.That(result, Is.EqualTo(model.Model));
     Assert.That(model.GetModel("1.1"), Is.EqualTo(null));
     Assert.That(model.GetModel("1.2"), Is.EqualTo(null));
 }
        public void ModelToString()
        {
            HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"));

            Assert.That(model.ToString(), Is.EqualTo(model.Model.ToString()));

            Assert.That(model.ToString(), Is.StringContaining("Class"));
            Assert.That(model.ToString(), Is.StringContaining("CLASS001"));
        }
        public void GetModel11()
        {
            HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"), new IModel[] { new CobolModel("Property", "PROP001"), });

            Assert.That(model.GetModel("1"), Is.EqualTo(model.Model));
            Assert.That(model.GetModel("1.0"), Is.EqualTo(null));
            Assert.That(model.GetModel("1.1"), Is.EqualTo(model.ChildModels[0]));
            Assert.That(model.GetModel("1.2"), Is.EqualTo(null));
        }
        private void RenderHierarchy(StringBuilder builder, HierarchyModel hierarchy, int depth, string path)
        {
            RenderModel(builder, hierarchy.Model, depth, path);

            int position = 0;
            foreach (var childModel in hierarchy.ChildModels)
            {
                position++;
                builder.AppendLine();
                Render(builder, childModel, depth + 1, path + "." + position);
            }
        }
        private void Render(XmlWriter xmlWriter, IModel renderModel, int depth, string path)
        {
            HierarchyModel hierarchy = renderModel as HierarchyModel;

            if (hierarchy != null)
            {
                RenderHierarchy(xmlWriter, hierarchy, depth, path);
            }
            else
            {
                RenderModel(xmlWriter, renderModel, depth, path);
            }
        }
Beispiel #9
0
        private void RenderHierarchy(StringBuilder builder, HierarchyModel hierarchy, int depth, string path)
        {
            RenderModel(builder, hierarchy.Model, depth, path);

            int position = 0;

            foreach (var childModel in hierarchy.ChildModels)
            {
                position++;
                builder.AppendLine();
                Render(builder, childModel, depth + 1, path + "." + position);
            }
        }
Beispiel #10
0
        private void Render(StringBuilder builder, IModel renderModel, int depth, string path)
        {
            HierarchyModel hierarchy = renderModel as HierarchyModel;

            if (hierarchy != null)
            {
                RenderHierarchy(builder, hierarchy, depth, path);
            }
            else
            {
                RenderModel(builder, renderModel, depth, path);
            }
        }
        private void RenderHierarchy(XmlWriter xmlWriter, HierarchyModel hierarchy, int depth, string path)
        {
            xmlWriter.WriteStartElement(hierarchy.Model.Name);

            IDictionary<string, string> parts = hierarchy.Model.GetModelParts();
            foreach (KeyValuePair<string, string> part in parts)
            {
                xmlWriter.WriteAttributeString(part.Key, part.Value);
            }
            xmlWriter.WriteAttributeString("path", path);

            int position = 0;
            foreach (var childModel in hierarchy.ChildModels)
            {
                position++;
                //xmlWriter.AppendLine();
                Render(xmlWriter, childModel, depth + 1, path + "." + position);
            }
            xmlWriter.WriteEndElement();
        }
 public void GetModel121()
 {
     HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"),
                                               new IModel[]
                                                   {
                                                       new HierarchyModel(new CobolModel("Property", "PROP001"), new IModel[]
                                                           {
                                                               new CobolModel("DataType", "DATA001"),
                                                           }),
                                                       new CobolModel("Property", "PROP002"),
                                                   });
     Assert.That(model.GetModel("1"), Is.EqualTo(model.Model));
     Assert.That(model.GetModel("1.0"), Is.EqualTo(null));
     Assert.That(model.GetModel("1.1"), Is.EqualTo(((HierarchyModel) model.ChildModels[0]).Model));
     Assert.That(model.GetModel("1.1.1"), Is.EqualTo(((HierarchyModel)model.ChildModels[0]).ChildModels[0]));
     Assert.That(model.GetModel("1.1.2"), Is.EqualTo(null));
     Assert.That(model.GetModel("1.2"), Is.EqualTo(model.ChildModels[1]));
     Assert.That(model.GetModel("1.2.2"), Is.EqualTo(null));
     Assert.That(model.GetModel("1.3"), Is.Null);
     Assert.That(model.GetModel("2.1"), Is.Null);
 }
        public void GetModel121()
        {
            HierarchyModel model = new HierarchyModel(new CobolModel("Class", "CLASS001"),
                                                      new IModel[]
            {
                new HierarchyModel(new CobolModel("Property", "PROP001"), new IModel[]
                {
                    new CobolModel("DataType", "DATA001"),
                }),
                new CobolModel("Property", "PROP002"),
            });

            Assert.That(model.GetModel("1"), Is.EqualTo(model.Model));
            Assert.That(model.GetModel("1.0"), Is.EqualTo(null));
            Assert.That(model.GetModel("1.1"), Is.EqualTo(((HierarchyModel)model.ChildModels[0]).Model));
            Assert.That(model.GetModel("1.1.1"), Is.EqualTo(((HierarchyModel)model.ChildModels[0]).ChildModels[0]));
            Assert.That(model.GetModel("1.1.2"), Is.EqualTo(null));
            Assert.That(model.GetModel("1.2"), Is.EqualTo(model.ChildModels[1]));
            Assert.That(model.GetModel("1.2.2"), Is.EqualTo(null));
            Assert.That(model.GetModel("1.3"), Is.Null);
            Assert.That(model.GetModel("2.1"), Is.Null);
        }
        private void RenderHierarchy(XmlWriter xmlWriter, HierarchyModel hierarchy, int depth, string path)
        {
            xmlWriter.WriteStartElement(hierarchy.Model.Name);

            IDictionary <string, string> parts = hierarchy.Model.GetModelParts();

            foreach (KeyValuePair <string, string> part in parts)
            {
                xmlWriter.WriteAttributeString(part.Key, part.Value);
            }
            xmlWriter.WriteAttributeString("path", path);

            int position = 0;

            foreach (var childModel in hierarchy.ChildModels)
            {
                position++;
                //xmlWriter.AppendLine();
                Render(xmlWriter, childModel, depth + 1, path + "." + position);
            }
            xmlWriter.WriteEndElement();
        }