예제 #1
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            SerializationTestObject sto = obj as SerializationTestObject;

            if ((System.Object)sto == null)
            {
                return(false);
            }

            // THIS CHECK FAILS! When AddChild() is used!
            bool childProof = false;

            if (child == null && sto.child == null)
            {
                childProof = true;
            }
            else if (child != null)
            {
                childProof = child.Equals(sto.child);
            }

            // Return true if the fields match:
            return(childProof && AreDictsEqual <string, string>(strDict, sto.strDict) &&
                   AreDictsEqual <string, string>(nullDict, sto.nullDict) &&
                   AreDictsEqual <int, int>(intDict, sto.intDict) &&
                   AreDictsEqual <short, short>(shortDict, sto.shortDict) &&
                   AreDictsEqual <ushort, ushort>(ushortDict, sto.ushortDict) &&
                   AreDictsEqual <long, long>(longDict, sto.longDict) &&
                   AreDictsEqual <float, float>(floatDict, sto.floatDict) &&
                   AreDictsEqual <double, double>(doubleDict, sto.doubleDict) &&
                   AreDictsEqual <byte, byte>(byteDict, sto.byteDict) &&
                   AreDictsEqual <char, char>(charDict, sto.charDict) &&
                   AreDictsEqual <TestEnum, TestEnum>(enumDict, sto.enumDict) &&
                   AreListsEqual <string>(strList, sto.strList) &&
                   AreListsEqual <string>(nullList, sto.nullList) &&
                   AreListsEqual <int>(intList, sto.intList) &&
                   AreListsEqual <short>(shortList, sto.shortList) &&
                   AreListsEqual <ushort>(ushortList, sto.ushortList) &&
                   AreListsEqual <long>(longList, sto.longList) &&
                   AreListsEqual <float>(floatList, sto.floatList) &&
                   AreListsEqual <double>(doubleList, sto.doubleList) &&
                   AreListsEqual <byte>(byteList, sto.byteList) &&
                   AreListsEqual <char>(charList, sto.charList) &&
                   AreListsEqual <TestEnum>(enumList, sto.enumList) &&
                   AreDictsEqual <bool, bool>(boolDict, sto.boolDict) &&
                   AreListsEqual <bool>(boolList, sto.boolList));
        }
예제 #2
0
        public void TestNestedObject()
        {
            MsgPackSerializer.DefaultContext.SerializationMethod = SerializationMethod.Array;
            var obj = new SerializationTestObject();

            byte[] msg   = MsgPackSerializer.SerializeObject(obj);
            var    desiz = MsgPackSerializer.Deserialize <SerializationTestObject>(msg);

            Assert.That(desiz != null, "No Nesting: null desiz");
            Assert.That(desiz.Equals(obj), "No Nesting: not equal");

            obj.AddChild();
            msg   = MsgPackSerializer.SerializeObject(obj);
            desiz = MsgPackSerializer.Deserialize <SerializationTestObject>(msg);

            Assert.That(desiz != null, "Nesting: null desiz");
            Assert.That(desiz.Equals(obj), "Nesting: not equal");
        }
예제 #3
0
 public SerializationTestObject AddChild()
 {
     child = new SerializationTestObject();
     return(this);
 }