Ejemplo n.º 1
0
        public void TestObjectsEqual()
        {
            Assert.IsFalse(DiffUtil.ObjectsEqual(
                               null,
                               new MockType {
                Some = 108, Thing = "Hello_Z"
            }
                               ), "first is null");

            Assert.IsFalse(DiffUtil.ObjectsEqual(
                               new MockType {
                Some = 108, Thing = "Hello_Z"
            },
                               null
                               ), "second is null");

            Assert.IsTrue(DiffUtil.ObjectsEqual(
                              null,
                              null
                              ), "both null");

            Assert.IsFalse(DiffUtil.ObjectsEqual(
                               new MockType {
                Some = 108, Thing = "Hello_Z"
            },
                               new MockType {
                Some = 108, Thing = "Hello_Z"
            }
                               ), "same value, but not same ref");

            var obj = new MockType {
                Some = 108, Thing = "Hello_Z"
            };

            Assert.IsTrue(DiffUtil.ObjectsEqual(
                              obj,
                              obj
                              ), "same value and same ref");

            Assert.IsTrue(DiffUtil.ObjectsEqual(
                              new { Some = 108, Thing = "Hello_Z" },
                              new { Some = 108, Thing = "Hello_Z" }
                              ), "same value and (anonymous obj that doesnt use ref)");
        }