public static void Should_consider_public_fields_when_comparing_complex_objects()
        {
            var expected = new Data
            {
                Id   = 1,
                Name = "Joe"
            };

            var actual = new Data
            {
                Id   = 2,
                Name = "Joe"
            };

            DeepAssert.AreNotEqual(actual, expected);
        }
예제 #2
0
        public static void When_exposing_internals_differences_in_internals_count()
        {
            var expected = new ClassWithPrivates(123)
            {
                Id       = 234,
                Name     = "Joe",
                Internal = "???"
            };

            var actual = new ClassWithPrivates(321)
            {
                Id       = 234,
                Name     = "Joe",
                Internal = "!!!"
            };

            var comparison = new ComparisonBuilder()
                             .ExposeInternalsOf <ClassWithPrivates>()
                             .Create();

            DeepAssert.AreNotEqual(actual, expected, comparison);
        }
예제 #3
0
        public void PersonEqualsTest()
        {
            Person mainPerson  = SinglePerson;
            Person otherPerson = SinglePerson;

            Assert.IsTrue(mainPerson.IsDeepEqual(otherPerson));

            otherPerson.Id = 5;
            Assert.IsFalse(mainPerson.IsDeepEqual(otherPerson));

            otherPerson.FirstName = "Jim";
            //mainPerson.WithDeepEqual(otherPerson).SkipDefault<Person>().IgnoreSourceProperty(x => x.Id).Assert();

            var comparison = new ComparisonBuilder()
                             .IgnoreProperty <Person>(x => x.Id)
                             .Create();

            DeepAssert.AreNotEqual(mainPerson, otherPerson, comparison);

            otherPerson.Id        = mainPerson.Id;
            otherPerson.FirstName = mainPerson.FirstName;

            Assert.IsTrue(mainPerson.IsDeepEqual(otherPerson));
        }
예제 #4
0
        public void FailResult()
        {
            var comparison = new EchoComparison(ComparisonResult.Fail);

            DeepAssert.AreNotEqual(a, b, comparison);
        }