コード例 #1
0
        public void Wrapper_AreEqual_CustomComparer_WorksProperly()
        {
            var property3Wrapper = new PropertyWrapper<MergeTestObject, string>(o => o.Property3, new SoftStringEqualityComparer(StringComparisonOptions.CaseInsensitive));

            var instance1 = new MergeTestObject()
            {
                Property3 = "foo"
            };

            var instance2 = new MergeTestObject()
            {
                Property3 = "FOO"
            };

            Conflict conflict;
            Assert.IsTrue(property3Wrapper.AreEqual(instance1, instance2, out conflict));
        }
コード例 #2
0
        public void Wrapper_AreEqual_ReturnsTrueAndNullConflict()
        {
            var property1Wrapper = new PropertyWrapper<MergeTestObject, int>(o => o.Property1);

            var instance1 = new MergeTestObject()
            {
                Property1 = 1
            };

            var instance2 = new MergeTestObject()
            {
                Property1 = instance1.Property1
            };

            Conflict conflict;
            Assert.IsTrue(property1Wrapper.AreEqual(instance1, instance2, out conflict));
            Assert.IsNull(conflict);
        }
コード例 #3
0
        public void Wrapper_AreEqual_DefaultComparer_WorksProperly()
        {
            var property1Wrapper = new PropertyWrapper<MergeTestObject, int>(o => o.Property1);
            var property3Wrapper = new PropertyWrapper<MergeTestObject, string>(o => o.Property3);

            var instance1 = new MergeTestObject()
            {
                Property1 = 1,
                Property3 = "foo"
            };

            var instance2 = new MergeTestObject()
            {
                Property1 = instance1.Property1,
                Property3 = instance1.Property3
            };

            Conflict conflict;
            Assert.IsTrue(property1Wrapper.AreEqual(instance1, instance2, out conflict));
            Assert.IsTrue(property3Wrapper.AreEqual(instance1, instance2, out conflict));
        }
コード例 #4
0
        public void Wrapper_AreEqual_ReturnsFalseAndConflictHasProperValues()
        {
            var property1Wrapper = new PropertyWrapper<MergeTestObject, int>(o => o.Property1);

            var instance1 = new MergeTestObject()
            {
                Property1 = 1
            };

            var instance2 = new MergeTestObject()
            {
                Property1 = 2
            };

            Conflict conflict;
            Assert.IsFalse(property1Wrapper.AreEqual(instance1, instance2, out conflict));

            Assert.IsNotNull(conflict);
            Assert.AreEqual("Property1", conflict.PropertyName);    // the property name in the lambda above
            Assert.AreEqual(instance1.Property1.ToString(), conflict.SourceValue);
            Assert.AreEqual(instance2.Property1.ToString(), conflict.DestinationValue);
        }
コード例 #5
0
ファイル: PropertyWrapperTests.cs プロジェクト: vermie/Merger
        public void Wrapper_AreEqual_DefaultComparer_WorksProperly()
        {
            var property1Wrapper = new PropertyWrapper<MergeTestObject, int>(o => o.Property1);
            var property3Wrapper = new PropertyWrapper<MergeTestObject, string>(o => o.Property3);

            var instance1 = new MergeTestObject()
            {
                Property1 = 1,
                Property3 = "foo"
            };

            var instance2 = new MergeTestObject()
            {
                Property1 = instance1.Property1,
                Property3 = instance1.Property3
            };

            Conflict conflict;
            Assert.IsTrue(property1Wrapper.AreEqual(instance1, instance2, out conflict));
            Assert.IsTrue(property3Wrapper.AreEqual(instance1, instance2, out conflict));
        }
コード例 #6
0
ファイル: PropertyWrapperTests.cs プロジェクト: vermie/Merger
        public void Wrapper_AreEqual_CustomComparer_WorksProperly()
        {
            var property3Wrapper = new PropertyWrapper<MergeTestObject, string>(o => o.Property3, new SoftStringEqualityComparer(StringComparisonOptions.CaseInsensitive));

            var instance1 = new MergeTestObject()
            {
                Property3 = "foo"
            };

            var instance2 = new MergeTestObject()
            {
                Property3 = "FOO"
            };

            Conflict conflict;
            Assert.IsTrue(property3Wrapper.AreEqual(instance1, instance2, out conflict));
        }
コード例 #7
0
ファイル: PropertyWrapperTests.cs プロジェクト: vermie/Merger
        public void Wrapper_AreEqual_ReturnsTrueAndNullConflict()
        {
            var property1Wrapper = new PropertyWrapper<MergeTestObject, int>(o => o.Property1);

            var instance1 = new MergeTestObject()
            {
                Property1 = 1
            };

            var instance2 = new MergeTestObject()
            {
                Property1 = instance1.Property1
            };

            Conflict conflict;
            Assert.IsTrue(property1Wrapper.AreEqual(instance1, instance2, out conflict));
            Assert.IsNull(conflict);
        }
コード例 #8
0
ファイル: PropertyWrapperTests.cs プロジェクト: vermie/Merger
        public void Wrapper_AreEqual_ReturnsFalseAndConflictHasProperValues()
        {
            var property1Wrapper = new PropertyWrapper<MergeTestObject, int>(o => o.Property1);

            var instance1 = new MergeTestObject()
            {
                Property1 = 1
            };

            var instance2 = new MergeTestObject()
            {
                Property1 = 2
            };

            Conflict conflict;
            Assert.IsFalse(property1Wrapper.AreEqual(instance1, instance2, out conflict));

            Assert.IsNotNull(conflict);
            Assert.AreEqual("Property1", conflict.PropertyName);    // the property name in the lambda above
            Assert.AreEqual(instance1.Property1.ToString(), conflict.SourceValue);
            Assert.AreEqual(instance2.Property1.ToString(), conflict.DestinationValue);
        }