Author: gert
Date: 2007-07-12 23:11:17 -0400 (Thu, 12 Jul 2007)
New Revision: 81919

Modified:
   trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorTests.cs
Log:
* PropertyDescriptorTests.cs: Added tests for Igor's fixes for
ShouldSerializeValue.


Modified: trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2007-07-13 
01:02:52 UTC (rev 81918)
+++ trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2007-07-13 
03:11:17 UTC (rev 81919)
@@ -1,3 +1,8 @@
+2007-07-13  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * PropertyDescriptorTests.cs: Added tests for Igor's fixes for
+       ShouldSerializeValue.
+
 2007-07-12  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * PropertyDescriptorTests.cs: Added GetEditorTest.

Modified: 
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorTests.cs
===================================================================
--- 
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorTests.cs    
    2007-07-13 01:02:52 UTC (rev 81918)
+++ 
trunk/mcs/class/System/Test/System.ComponentModel/PropertyDescriptorTests.cs    
    2007-07-13 03:11:17 UTC (rev 81919)
@@ -118,6 +118,38 @@
                        }
                }
 
+               class ShouldSerialize_Null_Default
+               {
+                       [DefaultValue (null)]
+                       public string Prop {
+                               get { return _prop; }
+                               set { _prop = value; }
+                       }
+
+                       public bool SerializeProp {
+                               get { return _serializeProp; }
+                               set { _serializeProp = value; }
+                       }
+
+                       public bool ShouldSerializeProp ()
+                       {
+                               return _serializeProp;
+                       }
+
+                       private string _prop;
+                       private bool _serializeProp;
+               }
+
+               class ShouldSerialize_No_Default
+               {
+                       public string Prop {
+                               get { return _prop; }
+                               set { _prop = value; }
+                       }
+
+                       private string _prop;
+               }
+
                class NoSerializeOrResetProp_test
                {
                        public int Prop {
@@ -234,6 +266,32 @@
                }
 
                [Test]
+               public void ShouldSerializeTest_No_Default ()
+               {
+                       PropertyDescriptor p = TypeDescriptor.GetProperties 
(typeof (ShouldSerialize_No_Default)) ["Prop"];
+                       ShouldSerialize_No_Default test = new 
ShouldSerialize_No_Default ();
+
+                       Assert.IsTrue (p.ShouldSerializeValue (test), "#1");
+                       test.Prop = "whatever";
+                       Assert.IsTrue (p.ShouldSerializeValue (test), "#2");
+               }
+
+               [Test]
+               public void ShouldSerializeTest_Null_Default ()
+               {
+                       PropertyDescriptor p = TypeDescriptor.GetProperties 
(typeof (ShouldSerialize_Null_Default)) ["Prop"];
+                       ShouldSerialize_Null_Default test = new 
ShouldSerialize_Null_Default ();
+
+                       Assert.IsFalse (p.ShouldSerializeValue (test), "#1");
+                       test.SerializeProp = true;
+                       Assert.IsFalse (p.ShouldSerializeValue (test), "#2");
+                       test.Prop = "whatever";
+                       Assert.IsTrue (p.ShouldSerializeValue (test), "#3");
+                       test.SerializeProp = false;
+                       Assert.IsTrue (p.ShouldSerializeValue (test), "#4");
+               }
+
+               [Test]
                public void CanResetTest_public ()
                {
                        PropertyDescriptor p = TypeDescriptor.GetProperties 
(typeof (CanReset_public_test))["Prop"];

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to