public void ShouldSerializeTest_ReadOnly () { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties ( typeof (ShouldSerialize_ReadOnly)); ShouldSerialize_ReadOnly test = new ShouldSerialize_ReadOnly (); PropertyDescriptor prop1PD = properties ["Prop1"]; PropertyDescriptor prop2PD = properties ["Prop2"]; PropertyDescriptor prop3PD = properties ["Prop3"]; PropertyDescriptor prop4PD = properties ["Prop4"]; PropertyDescriptor prop5PD = properties ["Prop5"]; PropertyDescriptor prop6PD = properties ["Prop6"]; PropertyDescriptor prop7PD = properties ["Prop7"]; PropertyDescriptor prop8PD = properties ["Prop8"]; PropertyDescriptor prop9PD = properties ["Prop9"]; Assert.IsFalse (prop1PD.ShouldSerializeValue (test), "#A1"); Assert.IsTrue (prop2PD.ShouldSerializeValue (test), "#A2"); Assert.IsFalse (prop3PD.ShouldSerializeValue (test), "#A3"); Assert.IsFalse (prop4PD.ShouldSerializeValue (test), "#A4"); Assert.IsFalse (prop5PD.ShouldSerializeValue (test), "#A5"); Assert.IsFalse (prop6PD.ShouldSerializeValue (test), "#A6"); Assert.IsFalse (prop7PD.ShouldSerializeValue (test), "#A7"); test.Prop1 = "whatever"; Assert.IsFalse (prop1PD.ShouldSerializeValue (test), "#B1"); test.Prop2 = "whatever"; Assert.IsTrue (prop2PD.ShouldSerializeValue (test), "#B2"); test.Prop3 = "whatever"; Assert.IsFalse (prop3PD.ShouldSerializeValue (test), "#B3"); test.Prop4 = "whatever"; Assert.IsFalse (prop4PD.ShouldSerializeValue (test), "#B4"); test.Prop7 = "whatever"; Assert.IsFalse (prop7PD.ShouldSerializeValue (test), "#B5"); test.Prop1 = "ok"; Assert.IsFalse (prop1PD.ShouldSerializeValue (test), "#C1"); test.SerializeProp3 = true; Assert.IsTrue (prop3PD.ShouldSerializeValue (test), "#C2"); test.SerializeProp4 = true; Assert.IsTrue (prop4PD.ShouldSerializeValue (test), "#C3"); test.SerializeProp5 = true; Assert.IsTrue (prop5PD.ShouldSerializeValue (test), "#C4"); test.SerializeProp6 = true; Assert.IsTrue (prop6PD.ShouldSerializeValue (test), "#C5"); test.Prop7 = "good"; Assert.IsFalse (prop7PD.ShouldSerializeValue (test), "#C6"); test.SerializeProp7 = true; Assert.IsTrue (prop7PD.ShouldSerializeValue (test), "#C7"); test.Prop7 = "good"; Assert.IsTrue (prop7PD.ShouldSerializeValue (test), "#C8"); // has both DesignerSerializationVisibility.Content and ShouldSerialize { return false } Assert.IsFalse (prop8PD.ShouldSerializeValue (test), "#D1"); // has DesignerSerializationVisibility.Content, no ShouldSerialize Assert.IsTrue (prop9PD.ShouldSerializeValue (test), "#D2"); }