Example #1
0
 protected static ComplexObject GetMock()
 {
     var o = new ComplexObject {RequiredProperty = "hello"};
     o.SimpleObject.AnotherProperty = "AnotherProperty";
     o.SimpleObject.SimpleProperty = "SimpleProperty";
     return o;
 }
        public void XmlSerializedObjectEqualsOriginalObject()
        {
            var original = GetMock();
            var fileName = WriteXml(original);

            // Test that retrieved object equals original object
            var serialized = new ComplexObject();
            var s = new XmlReaderSettings {IgnoreWhitespace = true};
            var r = XmlReader.Create(fileName, s);
            serialized.ReadXml(r);
            Assert.IsTrue(serialized.Equals(original));
        }
        public void RequiredValidator()
        {
            const string propertyName = "RequiredProperty";

            // instantiate an invalid object (required property is null).
            var o = new ComplexObject();
            AssertInvalidObject(o, propertyName, typeof(RequiredValidator));

            o.RequiredProperty = "hello";
            AssertValidObject(o, propertyName);
        }