Example #1
0
        public void ObjectsWithDifferentProps_ReturnsFalse()
        {
            var leftArray  = new { Numero = new Array[1, 2, 3], Letra = "A" };
            var rightArray = new { Numero = new Array[1, 5, 3], Letra = "A" };

            Assert.IsFalse(ObjectComparer.AreObjectsEqual(leftArray, rightArray));
        }
Example #2
0
        public void CompareDifferentObjectsTest()
        {
            var left  = BasicJson.GetDefault();
            var right = new BasicJson();

            Assert.IsFalse(ObjectComparer.AreObjectsEqual(left, right));
        }
Example #3
0
        public void CompareEqualsObjectsTest()
        {
            var left  = DateBasicJson.GetDateDefault();
            var right = DateBasicJson.GetDateDefault();

            Assert.IsTrue(ObjectComparer.AreObjectsEqual(left, right));
        }
        /// <summary>
        /// Serializes, decerializes and checks that objects are equal
        /// </summary>
        private void AssertSerializedAndDeserialized <TObject>(TObject obj, RuntimeTypeModel model)
        {
            byte[] bytes = ProtobufSerializer.SerializeProtocalBuffer(obj, model);
            var    back  = ProtobufSerializer.DeserializeProtocalBuffer <TObject>(bytes, model);

            bool result = ObjectComparer.AreObjectsEqual(obj, back);

            Assert.That(result, Is.True);
        }
Example #5
0
        public void ValidateEvents(params string[] names)
        {
            var expected = Expected().ToList();

            if (expected.Count != _aggregate.Changes.Count)
            {
                var message = string.Format("Events:\n{0} \n",
                                            string.Join("\n", _aggregate.Changes.Select(x => x.GetType().Name)));
                Assert.AreEqual(expected.Count, _aggregate.Changes.Count, message);
            }
            var ignore = IgnoreList.Create(names);

            for (int i = 0; i < _aggregate.Changes.Count; i++)
            {
                Assert.IsTrue(ObjectComparer.AreObjectsEqual(expected[i], _aggregate.Changes[i], ignore));
            }
        }
        private void Test(IEnumerable <Type> messageTypes, IEnumerable <Type> identityType, params Object[] objects)
        {
            var map = new Dictionary <Object, byte[]>();

            var messageTypeList  = messageTypes.ToList();
            var identityTypeList = identityType.ToList();

            var messageFactory  = new MessageFactory(messageTypeList);
            var identityFactory = new IdentityFactory(identityTypeList);

            var serializer = new ProtobufSerializer();

            serializer.RegisterMessages(messageFactory.MessageDefinitions);
            serializer.RegisterIdentities(identityFactory.IdentityDefinitions);

            foreach (var obj in objects)
            {
                map[obj] = serializer.Serialize(obj);
            }

            // reverse order of messages and identities
            messageTypeList.Reverse();
            identityTypeList.Reverse();

            messageFactory  = new MessageFactory(messageTypeList);
            identityFactory = new IdentityFactory(identityTypeList);

            serializer = new ProtobufSerializer();
            serializer.RegisterMessages(messageFactory.MessageDefinitions);
            serializer.RegisterIdentities(identityFactory.IdentityDefinitions);

            foreach (object obj in objects)
            {
                var back   = serializer.Deserialize(map[obj], obj.GetType());
                var result = ObjectComparer.AreObjectsEqual(obj, back);
                Assert.That(result, Is.True);
            }
        }
Example #7
0
        public void EqualsObjects_ReturnsTrue()
        {
            var left = new BasicJson
            {
                BoolData    = true,
                DecimalData = 1,
                IntData     = 1,
                NegativeInt = -1,
                StringData  = "A",
                StringNull  = null,
            };

            var right = new BasicJson
            {
                BoolData    = true,
                DecimalData = 1,
                IntData     = 1,
                NegativeInt = -1,
                StringData  = "A",
                StringNull  = null,
            };

            Assert.IsTrue(ObjectComparer.AreObjectsEqual(left, right));
        }
Example #8
0
 public void NullType_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
                                           ObjectComparer.AreObjectsEqual(DefaultObject, DefaultObject, null));
 }
Example #9
0
 public void DifferentObjects_ReturnsFalse()
 {
     Assert.IsFalse(ObjectComparer.AreObjectsEqual(DefaultObject, new DateBasicJson()));
 }
Example #10
0
 public void SameObjects_ReturnsTrue()
 {
     Assert.IsTrue(ObjectComparer.AreObjectsEqual(DefaultObject, DefaultObject));
 }
Example #11
0
        private void AssertObjectsEqual(object one, object two)
        {
            var result = ObjectComparer.AreObjectsEqual(one, two);

            Assert.IsTrue(result);
        }