public bool IsSame(CascadedClass other)
 {
     return
         ((MyEmptyClass == null
             ? other.MyEmptyClass == null
             : MyEmptyClass.IsSame(other.MyEmptyClass)) &&
          (MyPropertyClass == null
             ? other.MyPropertyClass == null
             : MyPropertyClass.IsSame(other.MyPropertyClass)));
 }
        public void FormatDocument()
        {
            var root = new CascadedClass
            {
                MyPropertyClass = { MyStringProperty = "Hello World!" }
            };
            var doc = Serializer.Format(Serializer.Serialize(root, null));

            Assert.NotNull(doc);
            Assert.AreEqual("!Test.CascadedClass\r\n{\r\n\tMyEmptyClass: !Test.EmptyClass\r\n\t{\r\n\t\t\r\n\t},\r\n\tMyPropertyClass: !Test.PropertyClass\r\n\t{\r\n\t\tMyStringProperty: \"Hello World!\"\r\n\t}\r\n}", doc);

            var readRoot = Serializer.Deserialize <CascadedClass>(doc, null);

            Assert.True(root.IsSame(readRoot));
        }
        public void NullReferencedClass()
        {
            var value = new CascadedClass(null);
            var w     = new Writer();
            var cs    = new ClassSerializer(typeof(CascadedClass));

            Assert.True(cs.Write(w, value, null));
            Assert.AreEqual("!Test.CascadedClass{MyEmptyClass:!Test.EmptyClass{},MyPropertyClass:?null}", w.ToString());

            var r      = new Reader(w.ToString());
            var result = cs.Read(r, null, null) as CascadedClass;

            Assert.IsNotNull(result);
            Assert.IsFalse(r.AnyLeft, "Any characters left.");
            Assert.IsTrue(value.IsSame(result), "Read back value is not the same.");
        }
 public ReferencedClass()
 {
     MyPropertyClass = new PropertyClassGuid();
     MyCascadedClass = new CascadedClass(MyPropertyClass);
 }