public void Equals_True_ComplexPoco_ArraysEqual_BothSameReference() { // Arrange var componentUnderTest = new FieldValueEqualityComparer(); FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly }); var strings = new[] { "1", "2" }; // Act var actual = componentUnderTest.Equals(new ComplexPoco { MyStrings = strings }, new ComplexPoco { MyStrings = strings }); // Assert Assert.AreEqual(true, actual); }
public void Equals_False_ComplexPoco_DictionaryNotEqual_NullDictionary_Rhs() { // Arrange var componentUnderTest = new FieldValueEqualityComparer(); FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly }); // Act var actual = componentUnderTest.Equals(new ComplexPoco { SimplePocoDictionary = new Dictionary <string, SimplePoco> { { "2", new SimplePoco() } } }, new ComplexPoco { SimplePocoDictionary = null }); // Assert Assert.AreEqual(false, actual); }
public void Equals_True_WithEqualityComparer_AtTopLevel() { // Arrange var componentUnderTest = new FieldValueEqualityComparer(); FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly }); var lhs = new SimplePoco { MyString = "1" }; var rhs = new InheritedSimplePoco { MyString = "xxx" }; // Act FieldValueEqualityComparer.AddFieldValueEqualityComparer(new SimplePocoEqualityComparer()); var actual = componentUnderTest.Equals(lhs, rhs); // Assert Assert.AreEqual(true, actual); }
public void Equals_False_List_SimpleType() { // Arrange var componentUnderTest = new FieldValueEqualityComparer(); FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly }); var list1 = new[] { "a", "b", "c" }; var list2 = new[] { "a", "a", "a" }; // Act var actual = componentUnderTest.Equals(list1, list2); // Assert Assert.AreEqual(false, actual); }
public void Equals_True_ComplexPoco_InList() { // Arrange var componentUnderTest = new FieldValueEqualityComparer(); FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly }); var lhs = new List <ComplexPoco> { new ComplexPoco(), new ComplexPoco() }; var rhs = new List <ComplexPoco> { new ComplexPoco(), new ComplexPoco() }; // Act var actual = componentUnderTest.Equals(lhs, rhs); // Assert Assert.AreEqual(true, actual); }
public void Equals_False_ComplexPoco_InDictionary_KeysDifferent() { // Arrange var componentUnderTest = new FieldValueEqualityComparer(); FieldValueEqualityComparer.SetAssembliesWithTypesToUseValueSemanticsOn(new[] { typeof(SimplePoco).Assembly }); var lhs = new Dictionary <string, ComplexPoco> { { "a", new ComplexPoco() }, { "b", new ComplexPoco() } }; var rhs = new Dictionary <string, ComplexPoco> { { "a", new ComplexPoco() }, { "c", new ComplexPoco() } }; // Act var actual = componentUnderTest.Equals(lhs, rhs); // Assert Assert.AreEqual(false, actual); }