public void CompareUsesFormatStringsFromConfiguration() { //Arrange. PersonEx2 p1 = ModelsHelper.CreatePersonEx2(); PersonEx2 p2 = ModelsHelper.CreatePersonEx2(); DateTime birthDate = DateTime.Now.AddYears(-20); p1.BirthDate = p2.BirthDate = birthDate; string fs1 = "yyyyMMdd"; string fs2 = "ddMMyyyy"; var config = ComparerConfigurator.Configure <PersonEx2>(true) .MapProperty(src => src.BirthDate, dst => dst.BirthDate, true, fs1, fs2); ObjectComparer comparer = config.CreateComparer(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult pcr = result[nameof(PersonEx2.BirthDate)]; pcr.Should().NotBeNull(); (pcr.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.StringCoercion); (pcr.Result & ComparisonResult.NotEqual).Should().Be(ComparisonResult.NotEqual); pcr.MapUsed.Should().NotBeNull(); pcr.MapUsed.ForceStringValue.Should().BeTrue(); pcr.MapUsed.FormatString.Should().Be(fs1); pcr.MapUsed.TargetFormatString.Should().Be(fs2); pcr.Value1.Should().NotBeNull(); pcr.Value1.Should().BeOfType <string>(); pcr.Value1.Should().Be(birthDate.ToString(fs1)); pcr.Value2.Should().NotBeNull(); pcr.Value2.Should().BeOfType <string>(); pcr.Value2.Should().Be(birthDate.ToString(fs2)); }
public void TestSimpleClassHierarchy() { var leftObject = new Element() { Name = "root", Content = new Element() { Name = "element1", Content = new Element() { Name = "element2", } } }; var rightObject = new Element() { Name = "root", Content = new Element() { Name = "element1", Content = new Element() { Name = "element2", } } }; ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory(); ObjectComparer comparer = new ObjectComparer(factory); bool match = comparer.Compare(leftObject, rightObject); Assert.True(match, "objects did not match"); }
public void CompareWithCustomComparer() { //Arrange. Mock <IComparer> customComparer = new Mock <IComparer>(); customComparer.Setup(m => m.Compare(It.IsAny <Genders>(), It.IsAny <Genders>())) .Returns(0) .Callback <Genders, Genders>((d1, d2) => { if (d1.GetType() != typeof(Genders) || d2.GetType() != typeof(Genders)) { throw new AssertionException("The arguments of the custom comparer are not of the expected type."); } }) .Verifiable("Custom comparer was not invoked."); Person p1 = ModelsHelper.CreatePerson(); Person p2 = ModelsHelper.CreatePerson(); ObjectComparer comparer = ObjectComparer.Create <Person>(); comparer.Comparers.Add(typeof(Genders), customComparer.Object); //Act. var result = comparer.Compare(p1, p2, out bool isDifferent); //Assert. customComparer.VerifyAll(); isDifferent.Should().BeFalse(); }
public void CompareTypesDoNotMatch() { var leftObject = new Element() { Content = 32, }; var rightObject = new Element() { Content = "stringvalue", }; ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory(); ObjectComparer comparer = new ObjectComparer(factory); IEnumerable <ObjectComparisonMismatch> mismatches; bool match = comparer.Compare(leftObject, rightObject, out mismatches); string[] expectedMismatches = new string[] { "ObjectTypesDoNotMatch:Left=RootObject.Content(32) Right=RootObject.Content(stringvalue)", }; string[] actualMismatches = StringFromMismatches(mismatches); Assert.False(match); Assert.True(actualMismatches.Length == expectedMismatches.Length); for (int index = 0; index < expectedMismatches.Length; index++) { Assert.Equal(expectedMismatches[index], actualMismatches[index]); } }
public void CompareIEnumerable() { Element leftObject = new Element() { Name = "root", Content = new List <string> { "hello1", "hello2", "hello3" } }; Element rightObject = new Element() { Name = "root", Content = new List <string> { "hello1", "hello2", "hello3" } }; ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory(); ObjectComparer comparer = new ObjectComparer(factory); bool match = comparer.Compare(leftObject, rightObject); Assert.True(match, "objects did not match"); }
public void CompareObjectWithLoopInSecondLevel() { Element leftObject = new Element() { Name = "RootElement", Content = new Element() { Name = "ChildElement" } }; // child points to root ((Element)leftObject.Content).Content = leftObject; Element rightObject = new Element() { Name = "RootElement", Content = new Element() { Name = "ChildElement" } }; // child points to parent ((Element)rightObject.Content).Content = rightObject; ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory(); ObjectComparer comparer = new ObjectComparer(factory); bool match = comparer.Compare(leftObject, rightObject); Assert.True(match, "object with loop did not match"); }
public void CompareObjectValuesDoNotMatch() { var leftObject = new Element() { Name = "Content1" }; var rightObject = new Element() { Name = "Content2" }; ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory(); ObjectComparer comparer = new ObjectComparer(factory); IEnumerable <ObjectComparisonMismatch> mismatches = comparer.Compare(leftObject, rightObject); string[] expectedMismatches = new string[] { "ObjectValuesDoNotMatch:Left=Element.Name(Content1) Right=Element.Name(Content2)", }; string[] actualMismatches = StringFromMismatches(mismatches); Assert.False(mismatches.None()); Assert.True(actualMismatches.Length == expectedMismatches.Length); for (int index = 0; index < expectedMismatches.Length; index++) { Assert.Equal(expectedMismatches[index], actualMismatches[index]); } }
public void ComplexTypeWithArrayProperties() { var obj1 = new TestObject3 { List = new[] { new TestObject2 { PropX = "xyz", PropY = new TestObject1 { Prop1 = "abc", Prop2 = 123 } }, new TestObject2 { PropX = "xyz", PropY = new TestObject1 { Prop1 = "abc", Prop2 = 123 } }, } }; var obj2 = new TestObject3 { List = new[] { new TestObject2 { PropX = "abc", PropY = new TestObject1 { Prop1 = "x1", Prop2 = 123 } }, new TestObject2 { PropX = "def", PropY = new TestObject1 { Prop1 = "x2", Prop2 = 456 } }, new TestObject2 { PropX = "ghi", PropY = new TestObject1 { Prop1 = "x3", Prop2 = 789 } }, } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(10, result.Count()); CheckComparison(result[0], ComparisonResult.NotEqual, ".List.Length", 2, 3); CheckComparison(result[1], ComparisonResult.NotEqual, ".List[0].PropX", "xyz", "abc"); CheckComparison(result[2], ComparisonResult.NotEqual, ".List[0].PropY.Prop1", "abc", "x1"); CheckComparison(result[3], ComparisonResult.Equal, ".List[0].PropY.Prop2", 123, 123); CheckComparison(result[4], ComparisonResult.NotEqual, ".List[1].PropX", "xyz", "def"); CheckComparison(result[5], ComparisonResult.NotEqual, ".List[1].PropY.Prop1", "abc", "x2"); CheckComparison(result[6], ComparisonResult.NotEqual, ".List[1].PropY.Prop2", 123, 456); CheckComparison(result[7], ComparisonResult.NotEqual, ".List[2].PropX", null, "ghi"); CheckComparison(result[8], ComparisonResult.NotEqual, ".List[2].PropY.Prop1", null, "x3"); CheckComparison(result[9], ComparisonResult.NotEqual, ".List[2].PropY.Prop2", null, 789); }
public void ComparesEachItemInArrayProperty() { var obj1 = new TestObject5 { PropX = new[] { new TestObject2 { Prop1 = 123 }, new TestObject2 { Prop1 = 456 }, } }; var obj2 = new TestObject5 { PropX = new[] { new TestObject2 { Prop1 = 789 }, new TestObject2 { Prop1 = 456 }, } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(3, result.Count); CheckComparison(result[0], ComparisonResult.Equal, ".PropX.Length", 2, 2); CheckComparison(result[1], ComparisonResult.NotEqual, ".PropX[0].Prop1", 123, 789); CheckComparison(result[2], ComparisonResult.Equal, ".PropX[1].Prop1", 456, 456); }
public void ComplexTypeWithArrayProperties() { var obj1 = new { List = new[] { new { PropX = "xyz", PropY = new { Prop1 = "abc", Prop2 = 123 } }, new { PropX = "xyz", PropY = new { Prop1 = "abc", Prop2 = 123 } }, } }; var obj2 = new { List = new[] { new { PropX = "abc", PropY = new { Prop1 = "x1", Prop2 = 123 } }, new { PropX = "def", PropY = new { Prop1 = "x2", Prop2 = 456 } }, new { PropX = "ghi", PropY = new { Prop1 = "x3", Prop2 = 789 } }, } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(10, result.Count); CheckComparison(result[0], ComparisonResult.NotEqual, ".List.Length", 2, 3); CheckComparison(result[1], ComparisonResult.NotEqual, ".List[0].PropX", "xyz", "abc"); CheckComparison(result[2], ComparisonResult.NotEqual, ".List[0].PropY.Prop1", "abc", "x1"); CheckComparison(result[3], ComparisonResult.Equal, ".List[0].PropY.Prop2", 123, 123); CheckComparison(result[4], ComparisonResult.NotEqual, ".List[1].PropX", "xyz", "def"); CheckComparison(result[5], ComparisonResult.NotEqual, ".List[1].PropY.Prop1", "abc", "x2"); CheckComparison(result[6], ComparisonResult.NotEqual, ".List[1].PropY.Prop2", 123, 456); CheckComparison(result[7], ComparisonResult.NotEqual, ".List[2].PropX", null, "ghi"); CheckComparison(result[8], ComparisonResult.NotEqual, ".List[2].PropY.Prop1", null, "x3"); CheckComparison(result[9], ComparisonResult.NotEqual, ".List[2].PropY.Prop2", null, 789); }
public void CompareCoercesToStringOnDemandFromConfiguration() { //Arrange. PersonEx p1 = ModelsHelper.CreatePersonEx(); PersonExWithPropMap p2 = ModelsHelper.CreatePersonExWithPropMapping(); var config = ComparerConfigurator.Configure <PersonEx, PersonExWithPropMap>(true) .MapProperty(src => src.Gender, dst => dst.Gender, true); ObjectComparer comparer = config.CreateComparer(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult pcr = result[nameof(Person.Gender)]; pcr.Should().NotBeNull(); (pcr.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.StringCoercion); pcr.MapUsed.Should().NotBeNull(); pcr.MapUsed.ForceStringValue.Should().BeTrue(); pcr.Value1.Should().NotBeNull(); pcr.Value1.Should().BeOfType <string>(); pcr.Value2.Should().NotBeNull(); pcr.Value2.Should().BeOfType <string>(); }
public void Compare_ComparesStringsCorrectly_CaseInsensitive(string first, string second, bool expectedEquals) { var options = new CompareOptions { DefaultStringComparison = StringComparison.OrdinalIgnoreCase }; ObjectComparer.Compare(first, second, out _, options).Should().Be(expectedEquals, "result was manually determined"); }
public void ThrowsIfObjectsDoNotHaveSameType() { var obj1 = new TestObject1(); var obj2 = new TestObject2(); var sut = new ObjectComparer(); sut.Compare(obj1, obj2); }
public void CompareObjects(object expected, object actual) { IEnumerable <ObjectComparisonMismatch> mismatches = _objectComparer.Compare(expected, actual); if (mismatches.Any()) { throw new ObjectMismatchException(mismatches); } }
public void ComparesObjectValuesIfObjectsHaveNoProperties() { var obj1 = new TestObject1(); var obj2 = new TestObject1(); var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(1, result.Count); CheckComparison(result[0], ComparisonResult.NotEqual, "", obj1, obj2); }
public void VerifyIgnoreList() { AnEntity entity1 = AnEntity.Create(10, null, 100); AnEntity entity2 = AnEntity.Create(10, null, 100); entity2.Value = 0; ObjectComparer comparer = new ObjectComparer(); comparer.AddIgnore("Value"); Assert.That(comparer.Compare(entity1, entity2)); }
public void CompareTypeMismatch(object o1, object o2) { //Arrange. ObjectComparer comparer = ObjectComparer.Create <Person, PersonByRefUdt>(); //Act. Action act = () => comparer.Compare(o1, o2); //Assert. act.Should().Throw <ArgumentException>(); }
public bool CompareServices(Service oldService, Service newService) { var difs = ObjectComparer.Compare(oldService, newService); // It always has 3 differences (Id, AddedDate, ModifiedDate) if (difs.Where(d => d.Prop != "Id" && d.Prop != "AddedDate" && d.Prop != "ModifiedDate").Any()) { return(true); } return(false); }
public void IfOneObjectIsNullTheOtherIsStillExploredRecursively() { var obj1 = new TestObject5 { PropX = new[] { new TestObject2 { Prop1 = 123 }, new TestObject2 { Prop1 = 456 }, } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, null).ToList(); Assert.AreEqual(3, result.Count); CheckComparison(result[0], ComparisonResult.NotEqual, ".PropX.Length", 2, 0); CheckComparison(result[1], ComparisonResult.NotEqual, ".PropX[0].Prop1", 123, null); CheckComparison(result[2], ComparisonResult.NotEqual, ".PropX[1].Prop1", 456, null); }
public void SimpleType() { var obj1 = new { Prop1 = "abc", Prop2 = 123 }; var obj2 = new { Prop1 = "abc", Prop2 = 345 }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(2, result.Count); CheckComparison(result[0], ComparisonResult.Equal, ".Prop1", "abc", "abc"); CheckComparison(result[1], ComparisonResult.NotEqual, ".Prop2", 123, 345); }
public void SimpleType() { var obj1 = new TestObject1 { Prop1 = "abc", Prop2 = 123 }; var obj2 = new TestObject1 { Prop1 = "abc", Prop2 = 345 }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(2, result.Count()); CheckComparison(result[0], ComparisonResult.Equal, ".Prop1", "abc", "abc"); CheckComparison(result[1], ComparisonResult.NotEqual, ".Prop2", 123, 345); }
public void CompareSameObject() { //Arrange. Person p1 = ModelsHelper.CreatePerson(); Person p2 = p1; ObjectComparer comparer = ObjectComparer.Create <Person>(); //Act. Action act = () => comparer.Compare(p1, p2); //Assert. act.Should().Throw <InvalidOperationException>(); }
public void ComplexType() { var obj1 = new { PropX = "xyz", PropY = new { Prop1 = "abc", Prop2 = 123 } }; var obj2 = new { PropX = "zyx", PropY = new { Prop1 = "abc", Prop2 = 345 } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(3, result.Count); CheckComparison(result[0], ComparisonResult.NotEqual, ".PropX", "xyz", "zyx"); CheckComparison(result[1], ComparisonResult.Equal, ".PropY.Prop1", "abc", "abc"); CheckComparison(result[2], ComparisonResult.NotEqual, ".PropY.Prop2", 123, 345); }
public void ComplexType() { var obj1 = new TestObject2 { PropX = "xyz", PropY = new TestObject1 { Prop1 = "abc", Prop2 = 123 } }; var obj2 = new TestObject2 { PropX = "zyx", PropY = new TestObject1 { Prop1 = "abc", Prop2 = 345 } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(3, result.Count()); CheckComparison(result[0], ComparisonResult.NotEqual, ".PropX", "xyz", "zyx"); CheckComparison(result[1], ComparisonResult.Equal, ".PropY.Prop1", "abc", "abc"); CheckComparison(result[2], ComparisonResult.NotEqual, ".PropY.Prop2", 123, 345); }
public void IndicesPastArrayEndAreTreatedAsNull() { var obj1 = new TestObject5 { PropX = new[] { new TestObject2 { Prop1 = 123 }, } }; var obj2 = new TestObject5 { PropX = new[] { new TestObject2 { Prop1 = 789 }, new TestObject2 { Prop1 = 456 }, } }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(3, result.Count); CheckComparison(result[0], ComparisonResult.NotEqual, ".PropX.Length", 1, 2); CheckComparison(result[1], ComparisonResult.NotEqual, ".PropX[0].Prop1", 123, 789); CheckComparison(result[2], ComparisonResult.NotEqual, ".PropX[1].Prop1", null, 456); }
public void PropertyNotFound() { //Arrange. PersonEx p1 = ModelsHelper.CreatePersonEx(); Person p2 = ModelsHelper.CreatePerson(); ObjectComparer comparer = ObjectComparer.Create <PersonEx, Person>(); //Act. var result = comparer.Compare(p1, p2, out bool isDifferent); //Assert. isDifferent.Should().BeFalse(); result[nameof(PersonEx.NickName)].Result.Should().Be(ComparisonResult.PropertyNotFound); }
public void ConfigurationIncludesAttributedPropertyMappings() { //Arrange. PersonExWithPropMap p1 = ModelsHelper.CreatePersonExWithPropMapping(); PersonEx p2 = ModelsHelper.CreatePersonEx(); var config = ComparerConfigurator.Configure <PersonExWithPropMap, PersonEx>(); ObjectComparer comparer = config.CreateComparer(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result[nameof(PersonExWithPropMap.NewNickName)].MapUsed.Should().NotBeNull(); }
public void CompareObjects() { // Create two objects with differing property values Person leftObject = new Person() { Name = "Person1", Age = 15, Parent = new Person() { Name = "ParentOfPerson1", } }; Person rightObject = new Person() { Name = "Person2", Age = 15, Parent = new Person() { Name = "ParentOfPerson2", } }; // Create the object graph factory ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory(); // Create a comparer using the factory ObjectComparer comparer = new ObjectComparer(factory); // Compare the objects IEnumerable <ObjectComparisonMismatch> mismatches; bool match = comparer.Compare(leftObject, rightObject, out mismatches); // Validate the mismatches when the objects do not match string[] expectedMismatches = new string[] { "ObjectValuesDoNotMatch:Left=RootObject.Parent.Name(ParentOfPerson1) Right=RootObject.Parent.Name(ParentOfPerson2)", "ObjectValuesDoNotMatch:Left=RootObject.Name(Person1) Right=RootObject.Name(Person2)", }; string[] actualMismatches = StringFromMismatches(mismatches); Assert.IsFalse(match); Assert.IsTrue(actualMismatches.Length == expectedMismatches.Length); for (int index = 0; index < expectedMismatches.Length; index++) { Assert.AreEqual(expectedMismatches[index], actualMismatches[index]); } }
public void IgnoreForComparisonAttributeIgnoreForOthers(Type p1Type, Person p1) { //Arrange. PersonEx p2 = ModelsHelper.CreatePersonEx(); ObjectComparer comparer = new ObjectComparer(p1Type, typeof(PersonEx)); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult proprtyResult = result[nameof(PersonExWithIgnore.NickName)]; proprtyResult.Should().NotBeNull(); proprtyResult.Result.Should().Be(ComparisonResult.PropertyIgnored); }
public void CompareNullablePropertiesSameType(bool date1Null, bool date2Null) { //Arrange. PersonEx2WithPropertyMap p1 = ModelsHelper.CreatePersonEx2WithPropertyMap(date1Null); PersonEx2 p2 = ModelsHelper.CreatePersonEx2(date2Null); ObjectComparer comparer = ObjectComparer.Create <PersonEx2WithPropertyMap, PersonEx2>(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult propResult = result[nameof(PersonEx2WithPropertyMap.DateOfBirth)]; propResult.Should().NotBeNull(); }
private void DemoGlobalConfiguration() { ObjectComparer.Configure(c => c .IncludePublicProperties() .IncludePublicFields() ); var objB = new ClassB(); var objC = new ClassC(); var result = ObjectComparer.Compare(objB, objC); Console.WriteLine($"Result:{result.AreEqual}"); Console.WriteLine(result.AggregateAllMessages()); Console.WriteLine(); }
public void Compare_ComparesComplexModels_DefaultOptions_SameObject() { const int id = 123; const string value = "fnord"; var date = DateTime.Now; const string link = @"http://example.com/subpage/?param=1&other=test"; var options = new CompareOptions().Use(EqualityComparer <Uri> .Default); var complex = new ComplexModel { Codes = new HashSet <string>(new[] { "A", "b", "cee" }), Link = new Uri(link), NumberSequence = new List <int> { 1, 2, 3 }, Simple = new SimpleModel { Id = id, Timestamp = date, Value = value }, Simples = new[] { new SimpleModel { Id = id + 1, Timestamp = date, Value = value }, new SimpleModel { Id = id + 2, Timestamp = date, Value = value } }, Nested = new ComplexModel { Codes = new HashSet <string>(new[] { "test1", "test2" }) } }; ReferenceEquals(complex, complex).Should().BeTrue("they are the same objects"); ObjectComparer.Compare(complex, complex, out _, options).Should().BeTrue("they are the same object"); }
public void CompareCoercesToStringOnAttributedDemand(bool date1Null, bool date2Null) { //Arrange. PersonExWithStringCoerce p1 = ModelsHelper.CreatePersonExWithStringCoerce(date1Null); PersonEx2 p2 = ModelsHelper.CreatePersonEx2(date2Null); ObjectComparer comparer = ObjectComparer.Create <PersonExWithStringCoerce, PersonEx2>(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult propResult = result[nameof(PersonExWithStringCoerce.DateOfBirth)]; propResult.Should().NotBeNull(); (propResult.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.StringCoercion); }
public void CompareNonNullableToNullableSameBaseType(bool nullDate) { //Arrange. PersonEx2NonNullable p1 = ModelsHelper.CreatePersonEx2NonNullable(); PersonEx2 p2 = ModelsHelper.CreatePersonEx2(nullDate); ObjectComparer comparer = ObjectComparer.Create <PersonEx2NonNullable, PersonEx2>(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult propResult = result[nameof(PersonEx2.BirthDate)]; propResult.Should().NotBeNull(); (propResult.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.Undefined, "Comparison without coercion is possible."); }
public void CompareCoercesToStringOnPropertyTypeMismatch() { //Arrange. PersonEx2 p1 = ModelsHelper.CreatePersonEx2(); PersonEx2StringDate p2 = ModelsHelper.CreatePersonEx2StringDate(); ObjectComparer comparer = ObjectComparer.Create <PersonEx2, PersonEx2StringDate>(); //Act. var result = comparer.Compare(p1, p2, out bool _); //Assert. result.Should().NotBeNull(); PropertyComparisonResult propResult = result[nameof(PersonEx2.BirthDate)]; propResult.Should().NotBeNull(); (propResult.Result & ComparisonResult.StringCoercion).Should().Be(ComparisonResult.StringCoercion); }
public void ReturnsNotEqualForStringProperty() { const string VALUE1 = "abc"; const string VALUE2 = "def"; var obj1 = new TestObject3 { Prop1 = VALUE1 }; var obj2 = new TestObject3 { Prop1 = VALUE2 }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(1, result.Count); CheckComparison(result[0], ComparisonResult.NotEqual, ".Prop1", VALUE1, VALUE2); }
public void ReturnsEqualForIntProperty() { const int VALUE = 123; var obj1 = new TestObject2 { Prop1 = VALUE }; var obj2 = new TestObject2 { Prop1 = VALUE }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(1, result.Count); CheckComparison(result[0], ComparisonResult.Equal, ".Prop1", VALUE, VALUE); }
public void ReturnsEqualForEnumProperty() { const Enum4 VALUE = Enum4.Something; var obj1 = new TestObject4 { Prop1 = VALUE }; var obj2 = new TestObject4 { Prop1 = VALUE }; var sut = new ObjectComparer(); var result = sut.Compare(obj1, obj2).ToList(); Assert.AreEqual(1, result.Count); CheckComparison(result[0], ComparisonResult.Equal, ".Prop1", VALUE, VALUE); }