public void Equal_TrueToSecondOnDatesDifferingByLessThanASecondWithCustomComparer() { DateTime one = DateTime.Parse("07:27:15.01"), two = DateTime.Parse("07:27:15.49"); Assert.True(MemberComparer.Equal(one, two, new[] { new DateComparer(DateComparisonType.TruncatedToSecond) })); }
public void Equal_FalseOnDifferentObjectsWithDifferentValues() { Guid sharedGuid = Guid.NewGuid(); Assert.False(MemberComparer.Equal(new { PropertyA = "B", Integer = 23, Guid = sharedGuid }, new { PropertyA = "A", Integer = 23, Guid = sharedGuid })); }
public void Equal_FalseOnAnonymousObjectsWithNestedObjectsWithDifferentValues() { var sub1 = new { PropertyB = "b1" }; var sub2 = new { PropertyB = "b2" }; Assert.False(MemberComparer.Equal(sub1, sub2)); }
public void Equal_TrueOnExceptionsWithinSameScopeOfSameType() { var exception = new ArgumentNullException("foo"); var exception2 = new ArgumentNullException("foo"); Assert.True(MemberComparer.Equal(exception, exception2)); }
public void Equal_TrueOnAnonymousObjectsWithNestedObjects() { var sub1 = new { PropertyB = "b1" }; var sub2 = new { PropertyB = "b1" }; Assert.True(MemberComparer.Equal(sub1, sub2)); }
public void Equal_TrueOnMatchedDictionaryObjectInstances() { DictionaryObj dobj1 = new DictionaryObj { ObjectDictionary = new Dictionary <int, ClassWithFieldsAndProperties> { { 1, new ClassWithFieldsAndProperties() { Foo = "one", Bar = "two" } }, { 2, new ClassWithFieldsAndProperties() { Foo = "three", Bar = "four" } } } }; DictionaryObj dobj2 = new DictionaryObj { ObjectDictionary = new Dictionary <int, ClassWithFieldsAndProperties> { { 1, new ClassWithFieldsAndProperties() { Foo = "one", Bar = "two" } }, { 2, new ClassWithFieldsAndProperties() { Foo = "three", Bar = "four" } } } }; Assert.True(MemberComparer.Equal(dobj1, dobj2)); }
public void Equal_FalseOnDatesDifferingByLessThanASecond() { DateTime one = DateTime.Parse("07:27:15.01"), two = DateTime.Parse("07:27:15.49"); Assert.False(MemberComparer.Equal(one, two)); }
public void Equal_FalseOnObjectsWithNestedObjectsWithDifferentValues() { var sub1 = new { PropertyB = "b1" }; var sub2 = new { PropertyB = "b2" }; Assert.False(MemberComparer.Equal(new { PropertyA = "A", Integer = 23, Sub = sub1 }, new { PropertyA = "A", Integer = 23, Sub = sub2 })); }
public void Equal_TrueOnObjectsWithNestedObjects() { var sub1 = new { PropertyB = "b1" }; var sub2 = new { PropertyB = "b1" }; Assert.True(MemberComparer.Equal(new { PropertyA = "A", Integer = 23, Sub = sub1 }, new { PropertyA = "A", Integer = 23, Sub = sub2 })); }
public void Equal_TrueOnDifferentObjectsWithSameValues() { Guid sharedGuid = Guid.NewGuid(); DateTime now = DateTime.Now; Assert.True(MemberComparer.Equal(new { PropertyA = "A", Integer = 23, Guid = sharedGuid, Date = now }, new { PropertyA = "A", Integer = 23, Guid = sharedGuid, Date = now })); }
public void Equal_TrueOnDoubleNestedObjectsWithSameValues() { //we've nested two levels deep var sub2 = new { PropertyC = "b2" }; var sub1 = new { PropertyB = "b1", Sub = sub2 }; Assert.True(MemberComparer.Equal(new { PropertyA = "A", Integer = 23, Sub = sub1 }, new { PropertyA = "A", Integer = 23, Sub = sub1 })); }
public void Equal_TrueOnInterfaces() { Assert.True(MemberComparer.Equal <IFoo>(new Foo() { Integer = 5 }, new Foo() { Integer = 5 })); }
public void Equal_FalseOnObjectsWithOneNullNestedObjectAndOneNonNullNestedObject() { var sub1 = new { PropertyB = "b1" }; var sub2 = new { PropertyB = "b2" }; sub2 = null; Assert.False(MemberComparer.Equal(new { PropertyA = "A", Integer = 23, Sub = sub1 }, new { PropertyA = "A", Integer = 23, Sub = sub2 })); }
public void Equal_ScopesComparisonToSpecifiedType() { Assert.True(MemberComparer.Equal <A>(new B() { Integer = 4, String = "Foo" }, new B() { Integer = 4, String = "Bar" })); }
public void Equal_TrueToSecondOnNestedDatesDifferingByLessThanASecondWithCustomComparer() { DateTime one = DateTime.Parse("07:27:15.01"), two = DateTime.Parse("07:27:15.49"); var a = new { Foo = 5, Bar = new { Now = one } }; var b = new { Foo = 5, Bar = new { Now = two } }; Assert.True(MemberComparer.Equal(one, two, new[] { new DateComparer(DateComparisonType.TruncatedToSecond) })); }
public void Equal_FalseOnClassWithMismatchFieldValues() { string Bar = "bar"; Assert.False(MemberComparer.Equal(new ClassWithFieldsAndProperties() { Foo = "456", Bar = Bar }, new ClassWithFieldsAndProperties() { Foo = "4567", Bar = Bar })); }
public void Equal_TrueOnClasswithPropertiesAndFields() { string Bar = "123", Foo = "456"; Assert.True(MemberComparer.Equal(new ClassWithFieldsAndProperties() { Bar = Bar, Foo = Foo }, new ClassWithFieldsAndProperties() { Bar = Bar, Foo = Foo })); }
public void Equal_TrueOnNullAnonymousObjects() { //anonymous types that look the same like these actually share a static type (as constructed by the compiler) var sub1 = new { PropertyB = "b1" }; sub1 = null; var sub2 = new { PropertyB = "b1" }; sub2 = null; Assert.True(MemberComparer.Equal(sub1, sub2)); }
public void Equal_TrueOnNestedRefToSameException() { var exception = new ArgumentNullException("foo"); Assert.True(MemberComparer.Equal(new ExceptionHolder() { Exception = exception }, new ExceptionHolder() { Exception = exception })); }
public void Equal_TrueOnClassWithMismatchedPropertiesAndFieldsWithCustomComparer() { string Bar = "bar"; Assert.True(MemberComparer.Equal(new ClassWithFieldsAndProperties() { Foo = "456", Bar = Bar }, new ClassWithFieldsAndProperties() { Foo = "4567", Bar = Bar }, new[] { new GenericEqualityComparer <ClassWithFieldsAndProperties>((a, b) => a.Bar == b.Bar) })); }
public void Equal_TrueOnObjectsWithNullNestedObjects() { //anonymous types that look the same like these actually share a static type (as constructed by the compiler) var sub1 = new { PropertyB = "b1" }; sub1 = null; var sub2 = new { PropertyB = "b1" }; sub2 = null; Assert.True(MemberComparer.Equal(new { PropertyA = "A", Integer = 23, Sub = sub1 }, new { PropertyA = "A", Integer = 23, Sub = sub2 })); }
public void Equal_FalseOnObjectsWithNestedCollections() { var nestedCollection1 = new { Property = "value", NestedProperties = new List <string>() { "a", "b" } }; var nestedCollection2 = new { Property = "value", NestedProperties = new List <string>() { "b", "a" } }; Assert.False(MemberComparer.Equal(nestedCollection1, nestedCollection2)); }
public void Equal_IgnoresStatics() { var a = new ClassWithStatics() { Value = "Foo" }; var b = new ClassWithStatics() { Value = "Foo" }; Assert.True(MemberComparer.Equal(a, b)); }
public void Equal_TrueOnNestedInterfaces() { Assert.True(MemberComparer.Equal <IBar>(new Bar() { Foo = new Foo() { Integer = 5 } }, new Bar() { Foo = new Foo() { Integer = 5 } })); }
public void Equal_TrueOnSameObject() { var anonymous = new { PropertyA = "A", Integer = 23, Guid = Guid.NewGuid() }; Assert.True(MemberComparer.Equal(anonymous, anonymous)); }
public void Equal_FalseOnMismatchedPrimitive() { Assert.False(MemberComparer.Equal(5, 15)); }
public void Equal_TrueOnKeyValuePair() { Assert.True(MemberComparer.Equal(new KeyValuePair <int, string>(1, "one"), new KeyValuePair <int, string>(1, "one"))); }
public void Equal_TrueOnPrimitive() { Assert.True(MemberComparer.Equal(3, 3)); }
public void Equal_FalseOnMismatchedString() { Assert.False(MemberComparer.Equal("foo", "bar")); }
public void Equal_TrueOnString() { Assert.True(MemberComparer.Equal("foo", "foo")); }