Example #1
0
        public void SerializeToString_IconsSectionExists()
        {
            MetaModel.MetaModel.Initialize();
            var sut        = new MetaModelYamlSerializer();
            var textWriter = new StringWriter();

            sut.Serialize(MetaModel.MetaModel.Instance, textWriter);
            var result = textWriter.ToString();

            Assert.IsTrue(result.Contains("icons"));
        }
Example #2
0
        public void SerializeToString()
        {
            MetaModel.MetaModel.Initialize();
            var sut        = new MetaModelYamlSerializer();
            var textWriter = new StringWriter();

            sut.Serialize(MetaModel.MetaModel.Instance, textWriter);
            var result = textWriter.ToString();

            Assert.IsNotNull(result);
        }
Example #3
0
        public void SerializeToString_EmptyMetaModel()
        {
            var model = new MetaModel.MetaModel();

            model.IconsList.Add(new ModelIcon("button_ok", "ok", "k"));
            var sut        = new MetaModelYamlSerializer();
            var textWriter = new StringWriter();

            sut.Serialize(model, textWriter);
            var result = textWriter.ToString();

            Assert.IsTrue(result.Contains("icons"));
        }
Example #4
0
        public void SerializeToString_NoNodeStyle()
        {
            MetaModel.MetaModel.Initialize(); //required by StyleImageGenerator
            var model = new MetaModel.MetaModel();

            model.IconsList.Add(new ModelIcon("button_ok", "ok", "k"));
            var sut        = new MetaModelYamlSerializer();
            var textWriter = new StringWriter();

            sut.Serialize(model, textWriter);
            var result = textWriter.ToString();

            Assert.IsFalse(result.Contains(MetaModelYamlSerializer.NodeStyles));
        }
Example #5
0
        public void SerializeToString_NodeStyle_NoLinePattern()
        {
            MetaModel.MetaModel.Initialize(); //required by StyleImageGenerator
            var model = new MetaModel.MetaModel();

            model.IconsList.Add(new ModelIcon("button_ok", "ok", "k"));
            var refNode = new MapNode(new MapTree(), "Text");

            refNode.Bold     = true;
            refNode.FontSize = 15;
            model.NodeStyles.Add(new NodeStyle("Stylish", refNode, false));
            var sut        = new MetaModelYamlSerializer();
            var textWriter = new StringWriter();

            sut.Serialize(model, textWriter);
            var result = textWriter.ToString();

            Assert.IsFalse(result.Contains(MapYamlSerializer.LinePattern));
        }
Example #6
0
        public void SerializeToString_NodeStyle()
        {
            var model = MetaModelHelper.Create();

            model.IconsList.Add(new ModelIcon("button_ok", "ok", "k"));
            var refNode = new MapNode(new MapTree(), "Text");

            refNode.Bold     = true;
            refNode.FontSize = 15;
            model.NodeStyles.Add(new NodeStyle("Stylish", refNode, false));
            var sut        = new MetaModelYamlSerializer();
            var textWriter = new StringWriter();

            sut.Serialize(model, textWriter);
            var result = textWriter.ToString();

            Assert.IsTrue(result.Contains(MetaModelYamlSerializer.NodeStyles));
            Assert.IsTrue(result.Contains("Stylish"));
        }
Example #7
0
        public void Save()
        {
            //xml
            //XmlSerializer formatter = new XmlSerializer(typeof(MetaModel));
            //formatter.Serialize(new StreamWriter(Application.UserAppDataPath + "/" +
            //     "Settings.xml"),this);

            //binary
            //using (var file = File.Create(MetaModel.GetFilePath()))
            //{
            //    ProtoBuf.Serializer.Serialize<MetaModel>(file, this);
            //}

            //yaml
            using (var file = new StreamWriter(GetFilePath()))
            {
                var s = new MetaModelYamlSerializer();
                s.Serialize(this, file);
            }
        }