Exemple #1
0
        public static void GetHashCode___Should_throw_NotSupportedException___When_constructed_with_null_getHashCodeFunc()
        {
            // Arrange
            var systemUnderTest = new LambdaBackedEqualityComparer <string>((x, y) => x.First() == y.First(), getHashCodeFunc: null);

            // Act
            var actual = Record.Exception(() => systemUnderTest.GetHashCode("abc"));

            // Assert
            actual.Should().BeOfType <NotSupportedException>();
        }
Exemple #2
0
        public static void Equals___Should_return_false___When_equalsFunc_returns_false_for_the_same_inputs()
        {
            // Arrange
            var systemUnderTest = new LambdaBackedEqualityComparer <string>((x, y) => x.First() == y.First());

            // Act
            var actual = systemUnderTest.Equals("abc", "def");

            // Assert
            actual.Should().BeFalse();
        }
Exemple #3
0
        public static void GetHashCode___Should_use_getHashCodeFunc___When_called()
        {
            // Arrange
            var hashCode = A.Dummy <int>();

            var systemUnderTest = new LambdaBackedEqualityComparer <string>(
                (x, y) => x.First() == y.First(),
                obj => hashCode);

            // Act
            var actual = systemUnderTest.GetHashCode(A.Dummy <string>());

            // Assert
            actual.Should().Be(hashCode);
        }