Exemplo n.º 1
0
    public void Should_use_provided_comparer()
    {
        var caseInsensitiveComparer = new ProjectionEqualityComparer <string, string>(s => s, StringComparer.OrdinalIgnoreCase);

        caseInsensitiveComparer.GetHashCode("value").Should().Be(caseInsensitiveComparer.GetHashCode("VALUE"));

        var caseSensitiveComparer = new ProjectionEqualityComparer <string, string>(s => s, StringComparer.Ordinal);

        caseSensitiveComparer.GetHashCode("value").Should().NotBe(caseSensitiveComparer.GetHashCode("VALUE"));
    }
Exemplo n.º 2
0
    public void Should_return_hashcode_of_nulls()
    {
        var comparer = new ProjectionEqualityComparer <string, string>(s => s);

        comparer.GetHashCode(null).Should().Be(0);
    }
Exemplo n.º 3
0
    public void Should_return_hashcode_of_projected_objects()
    {
        var comparer = new ProjectionEqualityComparer <string, string>(s => s.Substring(0, 3));

        comparer.GetHashCode("value").Should().Be(comparer.GetHashCode("val"));
    }