public void CultureTest() { var config = new YamlConfig(); config.Register(new LegacyTypeConverterFactory()); config.LookupAssemblies.Add(typeof(System.Drawing.PointF).Assembly); config.Culture = new System.Globalization.CultureInfo("da-DK"); var serializer = new Serializer(config); object obj = new System.Drawing.PointF(1.2f, 3.1f); var yaml = serializer.Serialize(obj); Assert.AreEqual( BuildResult( "!System.Drawing.PointF", "X: 1,2", "Y: 3,1" ), yaml ); var restore = serializer.Deserialize(yaml)[0]; Assert.AreEqual(obj, restore); obj = new System.Drawing.Point(1, 3); yaml = serializer.Serialize(obj); Assert.AreEqual( BuildResult( "!System.Drawing.Point 1; 3" ), yaml ); restore = serializer.Deserialize(yaml)[0]; Assert.AreEqual(obj, restore); YamlNode.DefaultConfig.Culture = System.Globalization.CultureInfo.CurrentCulture; }
public void TestOmitRootNodesTag() { var obj = new TestClass(); obj.list.Add(new ChildClass()); var serializer = new Serializer(); var yaml= serializer.Serialize(obj); Assert.AreEqual( BuildResult( "!YamlSerializerTest.TestClass", "list: ", " Capacity: 4", " ICollection.Items: ", " - !YamlSerializerTest.ChildClass", " list: ", " Capacity: 0" ), yaml ); var config = new YamlConfig(); config.OmitTagForRootNode = true; serializer = new Serializer(config); yaml = serializer.Serialize(obj); Assert.AreEqual( BuildResult( "list: ", " Capacity: 4", " ICollection.Items: ", " - !YamlSerializerTest.ChildClass", " list: ", " Capacity: 0" ), yaml ); }