[gxml] GomProperty: Added support to set values



commit 89d0c778a53f48c2da40261686c214a34494dfb8
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Nov 6 21:29:57 2016 -0600

    GomProperty: Added support to set values
    
    Added set values to Basic types. Added Unit Tests.

 gxml/GomProperty.vala          |    5 +++++
 test/GomSerializationTest.vala |   13 +++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gxml/GomProperty.vala b/gxml/GomProperty.vala
index 92a43fe..f95820f 100644
--- a/gxml/GomProperty.vala
+++ b/gxml/GomProperty.vala
@@ -55,10 +55,12 @@ public class GXml.GomDouble : Object, GomProperty {
   }
   public uint decimals { get; set; default = 4; }
   public double get_double () { return _value; }
+  public void set_double (double value) { _value = value; }
 }
 
 public class GXml.GomFloat : GomDouble {
   public float get_float () { return (float) _value; }
+  public void set_float (float value) { _value = value; }
 }
 
 
@@ -78,6 +80,7 @@ public class GXml.GomInt : Object, GomProperty {
     }
   }
   public int get_integer () { return _value; }
+  public void set_integer (int value) { _value = value; }
 }
 
 public class GXml.GomBoolean : Object, GomProperty {
@@ -96,6 +99,7 @@ public class GXml.GomBoolean : Object, GomProperty {
     }
   }
   public bool get_boolean () { return _value; }
+  public void set_boolean (bool value) { _value = value; }
 }
 
 public class GXml.GomEnum : Object, GomProperty {
@@ -129,4 +133,5 @@ public class GXml.GomEnum : Object, GomProperty {
     construct set { _enum_type = value; }
   }
   public int get_enum () { return (int) _value; }
+  public void set_enum (int value) { _value = value; }
 }
diff --git a/test/GomSerializationTest.vala b/test/GomSerializationTest.vala
index 495ff57..5ae8f2b 100644
--- a/test/GomSerializationTest.vala
+++ b/test/GomSerializationTest.vala
@@ -118,7 +118,7 @@ class GomSerializationTest : GXmlTest  {
       var parser = new XParser (this);
       return parser.write_string ();
     }
-    public enum Enum {
+    public enum TensionTypeEnum {
       AC,
       DC
     }
@@ -139,7 +139,7 @@ class GomSerializationTest : GXmlTest  {
     }
     public class TensionType : GomEnum {
       construct {
-        _enum_type = typeof (Enum);
+        _enum_type = typeof (TensionTypeEnum);
         _attribute_name = "TensionType";
       }
     }
@@ -316,6 +316,15 @@ class GomSerializationTest : GXmlTest  {
       assert (s != null);
       GLib.message ("DOC:"+s);
       assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"0.0000\" TensionType=\"ac\" Tension=\"0\"/>" in 
s);
+      m.is_on.set_boolean (true);
+      m.torque.set_double (3.1416);
+      m.speed.set_float ((float) 3600.1011);
+      m.tension_type.set_enum ((int) Motor.TensionTypeEnum.DC);
+      m.tension.set_integer (125);
+      s = m.to_string ();
+      assert (s != null);
+      GLib.message ("DOC:"+s);
+      assert ("<Motor On=\"true\" Torque=\"3.1416\" Speed=\"3600.1011\" TensionType=\"dc\" 
Tension=\"125\"/>" in s);
     });
     Test.add_func ("/gxml/gom-serialization/read/properties", () => {
       var b = new Book ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]