public void WithEqualityComparerReturningTheArgumentIntegerValuesModulusByTwoAndAndWithComparer_Should_ComputeTheSameHashCode() { var builder1 = new global::HashCode.Builder(); var builder2 = new global::HashCode.Builder(); var equalityComparer = new CallbackEqualityComparer <int>((x, y) => true, (obj) => obj % 2); var comparer = new CallbackComparer <int>((x, y) => (x == y ? 0 : (x < y) ? -1 : +1)); // Act builder1.AddIgnoreOrder(equalityComparer, comparer, 4, 3); builder2.Add(equalityComparer, 1, 2); // Assert builder1.Build().Should().Be(builder2.Build()); }
public void WithEqualityComparerAlwaysReturningTheSameHashCode_Should_ComputeTheSameHashCodeForDifferentItems() { // Arrange var builder1 = new global::HashCode.Builder(); var builder2 = new global::HashCode.Builder(); var equalityComparer = new CallbackEqualityComparer <string>((x, y) => true, (obj) => 1337); // Act builder1.Add(equalityComparer, "test", "1"); builder2.Add(equalityComparer, "item", "a"); // Assert builder1.Build().Should().Be(builder2.Build()); }