public void OrderSensitiveValueComparisonListTests_ValueComparer() { // Two identical lists with elements that are // distinct objects, by reference. OrderSensitiveValueComparisonList <ArtifactChange> listOne = CreateTestList(ArtifactChange.ValueComparer); OrderSensitiveValueComparisonList <ArtifactChange> listTwo = CreateTestList(ArtifactChange.ValueComparer); // Every list s/be equal to itself listOne.Equals(listOne).Should().Be(true); // As initialized, these objects are different, due // to a unique GUID property on each list listOne.Equals(listTwo).Should().Be(false); // Make the two lists equivalent, by value listTwo[2].SetProperty(DIFFERENTIATING_PROPERTY_NAME, listOne[2].GetProperty <Guid>(DIFFERENTIATING_PROPERTY_NAME)); listOne.Equals(listTwo).Should().Be(true); ArtifactChange toSwap = listTwo[0]; listTwo[0] = listTwo[1]; listTwo[1] = toSwap; // We have reordered two objects that are themselves identical. // by value. The comparison should still succeed. listOne.Equals(listTwo).Should().Be(true); }
public void OrderSensitiveValueComparisonListTests_DefaultObjectComparer() { var equalityComparer = new DefaultObjectComparer <ArtifactChange>(); OrderSensitiveValueComparisonList <ArtifactChange> listOne = CreateTestList(equalityComparer); // Populate the second list with references from the first. var listTwo = new OrderSensitiveValueComparisonList <ArtifactChange>(equalityComparer); for (int i = 0; i < listOne.Count; i++) { listTwo.Add(listOne[i]); } // Every list s/be equal to itself. listOne.Equals(listOne).Should().Be(true); // Two lists with shared objects, by reference, in the same // order should be regarded as equivalent. listOne.Equals(listTwo).Should().Be(true); ArtifactChange toSwap = listTwo[0]; listTwo[0] = listTwo[1]; listTwo[1] = toSwap; // We have reordered two objects that are themselves identical. // The comparison should fail as the order of references changed. listOne.Equals(listTwo).Should().Be(false); }