Example #1
0
        // methods
        /// <inheritdoc/>
        public bool Equals(ConnectionDescription other)
        {
            if (other == null)
            {
                return(false);
            }

            return
                (_connectionId.StructurallyEquals(other._connectionId) &&
                 _helloResult.Equals(other._helloResult));
        }
        // methods
        /// <inheritdoc/>
        public bool Equals(ConnectionDescription other)
        {
            if (other == null)
            {
                return(false);
            }

            return
                (_buildInfoResult.Equals(other._buildInfoResult) &&
                 _connectionId.StructurallyEquals(other._connectionId) &&
                 _isMasterResult.Equals(other._isMasterResult));
        }
Example #3
0
        public void Equals_should_return_expected_result(
            int port1,
            int localValue1,
            int serverValue1,
            int port2,
            int localValue2,
            int serverValue2,
            bool expectedEqualsResult,
            bool expectedStructurallyEqualsResult)
        {
            var clusterId = new ClusterId();
            var serverId1 = new ServerId(clusterId, new DnsEndPoint("localhost", port1));
            var serverId2 = new ServerId(clusterId, new DnsEndPoint("localhost", port2));

            var subject1 = new ConnectionId(serverId1, localValue1).WithServerValue(serverValue1);
            var subject2 = new ConnectionId(serverId2, localValue2).WithServerValue(serverValue2);

            // note: Equals ignores the server values and StructurallyEquals compares all fields
            var equalsResult1             = subject1.Equals(subject2);
            var equalsResult2             = subject2.Equals(subject1);
            var structurallyEqualsResult1 = subject1.StructurallyEquals(subject2);
            var structurallyEqualsResult2 = subject2.StructurallyEquals(subject1);
            var hashCode1 = subject1.GetHashCode();
            var hashCode2 = subject2.GetHashCode();

            equalsResult1.Should().Be(expectedEqualsResult);
            equalsResult2.Should().Be(expectedEqualsResult);
            structurallyEqualsResult1.Should().Be(expectedStructurallyEqualsResult);
            structurallyEqualsResult2.Should().Be(expectedStructurallyEqualsResult);
            (hashCode1 == hashCode2).Should().Be(expectedEqualsResult);
        }