コード例 #1
0
    public void Equals_Object_Returns_False_When_Other_Is_Null()
    {
        // Arrange
        var value = new ValueCollection <string>(new[] { "a", "b", "C" });

        // Act
        var actual = value.Equals((object?)null);

        // Assert
        actual.Should().BeFalse();
    }
コード例 #2
0
    public void Equals_Object_Returns_True_On_Same_Reference()
    {
        // Arrange
        var value = new ValueCollection <string>(new[] { "a", "b", "C" });

        // Act
        var actual = value.Equals((object)value);

        // Assert
        actual.Should().BeTrue();
    }
コード例 #3
0
    public void Can_Compare_Two_Different_ValueCollections_With_Default_EqualityComparer_2()
    {
        // Arrange
        var value1 = new ValueCollection <string>(new[] { "a", "b" });
        var value2 = new ValueCollection <string>(new[] { "a", "b", "c" });

        // Act
        var actual = value1.Equals(value2);

        // Assert
        actual.Should().BeFalse();
    }
コード例 #4
0
    public void Equals_Object_Two_ValueCollections_Returns_True_When_Value_Equal()
    {
        // Arrange
        var value1 = new ValueCollection <string>(new[] { "a", "b", "c" });
        var value2 = new ValueCollection <string>(new[] { "a", "b", "c" });

        // Act
        var actual = value1.Equals((object)value2);

        // Assert
        actual.Should().BeTrue();
    }
コード例 #5
0
    public void Can_Compare_Two_ValueCollections_With_Custom_EqualityComparer()
    {
        // Arrange
        var equalityComparerMock = new Mock <IEqualityComparer <string> >();

        equalityComparerMock.Setup(x => x.Equals(It.IsAny <string>(), It.IsAny <string>()))
        .Returns <string, string>((x, y) => x.ToUpperInvariant() == y.ToUpperInvariant());
        var value1 = new ValueCollection <string>(new[] { "a", "b", "C" }, equalityComparerMock.Object);
        var value2 = new ValueCollection <string>(new[] { "A", "b", "c" }, equalityComparerMock.Object);

        // Act
        var actual = value1.Equals(value2);

        // Assert
        actual.Should().BeTrue();
    }