Exemple #1
0
        public void PrivateFieldsShouldNotBeComparedWithReadOnlyCollections()
        {
            //ReadOnlyCollections will throw exceptions on accessing _syncRoot
            var baseCollection = new List<ObjectWithPrivateMembers>()
            {
                new ObjectWithPrivateMembers(
                    someIntField: 1,
                    somePrivateIntField: 2,
                    somePrivateIntProperty: 2),
                new ObjectWithPrivateMembers(
                    someIntField: 1,
                    somePrivateIntField: 3,
                    somePrivateIntProperty: 3)
            };

            var antagonistCollection = new List<ObjectWithPrivateMembers>()
            {
                new ObjectWithPrivateMembers(
                    someIntField:1,
                    somePrivateIntField:2,
                    somePrivateIntProperty:4),
                new ObjectWithPrivateMembers(
                    someIntField:1,
                    somePrivateIntField:3,
                    somePrivateIntProperty:5)
            };

            var baseObject = new ObjectWithReadOnlyCollectionField() {Collection = baseCollection.AsReadOnly()};
            var antagonist = new ObjectWithReadOnlyCollectionField() {Collection = antagonistCollection.AsReadOnly()};

            var calc = new NetDiff.DiffCalculator();

            var result = calc.Diff(baseObject, antagonist);

            Assert.Equal(true, result.ValuesMatch);
        }