Exemplo n.º 1
0
        public void TestCases()
        {
            DmSerializer serializer = new DmSerializer();

            foreach (var obj in SerializableObjects.GetObjects())
            {
                try
                {
                    var cliByte = serializer.Serialize(obj);
                    var ob2     = serializer.Deserialize(cliByte);

                    bool areEqual = false;


                    if (EqualityHelpers.IsDictionary(obj.GetType()))
                    {
                        areEqual = EqualityHelpers.DictionariesAreEqual((IDictionary)obj, (IDictionary)ob2);
                    }
                    else if (EqualityHelpers.IsEnumerable(obj.GetType()))
                    {
                        areEqual = EqualityHelpers.ArraysAreEqual((IEnumerable)obj, (IEnumerable)ob2);
                    }
                    else
                    {
                        areEqual = obj.Equals(ob2);
                    }

                    Assert.True(areEqual, $"Type: {obj.GetType()}: Instance 1 is not equal to deserialized instance.");
                }
                catch (Exception ex)
                {
                    Assert.True(false, ($"Object 1 Type : {obj.GetType()} - is not serializable. ({ex.Message})"));
                }
            }
        }
Exemplo n.º 2
0
 public override bool Equals(object obj)
 {
     if (!(obj is StructContainingArraysOfOtherStructs))
     {
         return(false);
     }
     return(EqualityHelpers.ArraysAreEqual(Nested, ((StructContainingArraysOfOtherStructs)obj).Nested));
 }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            ObjectWithArrays o = obj as ObjectWithArrays;

            if (o == null)
            {
                return(false);
            }

            return
                (EqualityHelpers.ArraysAreEqual(IntArray, o.IntArray) &&
                 EqualityHelpers.ArraysAreEqual(StringArray, o.StringArray) &&
                 EqualityHelpers.ArraysAreEqual(TreeArray, o.TreeArray) &&
                 EqualityHelpers.ArraysAreEqual(ByteArray, o.ByteArray) &&
                 EqualityHelpers.ArraysAreEqual(JaggedArray, o.JaggedArray) &&
                 EqualityHelpers.ArraysAreEqual(MultiDimensionalArray, o.MultiDimensionalArray));
        }