From 6266b290a469985e82e096959de6a23c2bdb3a9a Mon Sep 17 00:00:00 2001 From: Daniel Espinosa Date: Thu, 3 Nov 2016 17:03:02 -0600 Subject: [PATCH] GOM: Added test case for ignored properties --- test/GomSerializationTest.vala | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/test/GomSerializationTest.vala b/test/GomSerializationTest.vala index 39b24fa7..d81b92ca 100644 --- a/test/GomSerializationTest.vala +++ b/test/GomSerializationTest.vala @@ -31,8 +31,17 @@ class GomSerializationTest : GXmlTest { } public string to_string () { return (_document as GomDocument).to_string (); } } + public class Computer : GomElement { + [Description (nick="::Model")] + public string model { get; set; } + public string ignore { get; set; } // ignored property + construct { + _local_name = "Computer"; + } + public string to_string () { return (_document as GomDocument).to_string (); } + } public static void add_tests () { - Test.add_func ("/gxml/gom-serialization/write", () => { + Test.add_func ("/gxml/gom-serialization/write/properties", () => { var b = new Book (); string s = b.to_string (); assert (s != null); @@ -41,10 +50,20 @@ class GomSerializationTest : GXmlTest { assert (b.get_attribute ("name") == "My Book"); s = b.to_string (); GLib.message ("DOC:"+s); - foreach (ParamSpec spec in b.get_class ().list_properties ()) { - if ("::" in spec.get_nick ()) - GLib.message ("Name: "+spec.name+ " Nick: "+spec.get_nick ()); - } + }); + Test.add_func ("/gxml/gom-serialization/write/property-ignore", () => { + var c = new Computer (); + string s = c.to_string (); + assert (s != null); + assert ("" in s); + c.model = "T3456-E"; + c.ignore = "Nothing"; + assert (c.model == "T3456-E"); + assert (c.get_attribute ("model") == "T3456-E"); + assert (c.ignore == "Nothing"); + assert (c.get_attribute ("ignore") == "Nothing"); + s = c.to_string (); + GLib.message ("DOC:"+s); }); } } -- GitLab