public void test_copy() { CharTextProperty foo = new CharTextProperty("blah"), bar = foo.copy(); Assert.IsFalse(ReferenceEquals(foo, bar)); Assert.AreEqual(foo.value, bar.value); }
public void test_equals() { CharTextProperty foo = new CharTextProperty("blah"), bar = foo.copy(), baz = new CharTextProperty("bloh"); Assert.IsTrue(foo.equals(bar)); Assert.IsTrue(bar.equals(foo)); Assert.IsFalse(foo.equals(baz)); Assert.IsFalse(baz.equals(foo)); }
public void test_serialization() { CharTextProperty foo = new CharTextProperty("blah"), bar; DataContractSerializer fmt = new DataContractSerializer(typeof(CharTextProperty)); using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { fmt.WriteObject(ms, foo); ms.Seek(0, System.IO.SeekOrigin.Begin); System.Xml.XmlDictionaryReader xr = System.Xml.XmlDictionaryReader.CreateTextReader(ms, new System.Xml.XmlDictionaryReaderQuotas()); bar = (CharTextProperty)(fmt.ReadObject(xr, true)); } Assert.AreEqual(foo.value, bar.value); }
public void test_constructor_argument() { CharTextProperty tprop = new CharTextProperty("bloh"), subprop; CharDictProperty foo = new CharDictProperty(new Dictionary <string, CharProperty>() { ["blah"] = tprop }); Assert.AreEqual(foo.value.Count, 1); Assert.IsTrue(foo.value.ContainsKey("blah")); subprop = foo.value["blah"] as CharTextProperty; Assert.IsNotNull(subprop); Assert.AreEqual(subprop.value, tprop.value); }
public void test_add() { CharDictProperty foo = new CharDictProperty(), bar = new CharDictProperty(); CharTextProperty tprop = new CharTextProperty("blah"); CharNumProperty nprop = new CharNumProperty(1.23m); foo.value["Some Text"] = tprop; bar.value["Some Number"] = nprop; foo.add(bar); Assert.AreEqual(foo.value.Count, 2); Assert.IsTrue(foo.value.ContainsKey("Some Text")); Assert.IsTrue(foo.value.ContainsKey("Some Number")); Assert.IsFalse(ReferenceEquals(foo.value["Some Number"], bar.value["Some Number"])); Assert.AreEqual((foo.value["Some Number"] as CharNumProperty).value, (bar.value["Some Number"] as CharNumProperty).value); }
public void test_equals() { CharDictProperty foo = new CharDictProperty(), bar, baz = new CharDictProperty(); CharTextProperty tprop = new CharTextProperty("blah"); CharNumProperty nprop = new CharNumProperty(1.23m); CharSetProperty sprop = new CharSetProperty(); sprop.value.Add("bloh"); sprop.value.Add("bleh"); foo.value["Some Text"] = tprop; foo.value["Some Number"] = nprop; foo.value["Some Collection"] = sprop; bar = foo.copy(); baz.value["Some Text"] = tprop; Assert.IsTrue(foo.equals(bar)); Assert.IsTrue(bar.equals(foo)); Assert.IsFalse(foo.equals(baz)); Assert.IsFalse(baz.equals(foo)); }