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)); }
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); }
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)); }
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); }