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")); }
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); }
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")); }
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)); }
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)); }
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")); }
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); } }