Exemplo n.º 1
0
        public void GetHashCode_Test(bool expected,
                                     string xHead,
                                     string xTail,
                                     string yHead,
                                     string yTail)
        {
            // Arrange
            _ = IPAddress.TryParse(xHead, out var xHeadAddress);
            _ = IPAddress.TryParse(xTail, out var xTailAddress);

            var xAddressRange = new IPAddressRange(xHeadAddress, xTailAddress);

            _ = IPAddress.TryParse(yHead, out var yHeadAddress);
            _ = IPAddress.TryParse(yTail, out var yTailAddress);

            var yAddressRange = new IPAddressRange(yHeadAddress, yTailAddress);

            // Act
            var xHash  = xAddressRange.GetHashCode();
            var yHash  = yAddressRange.GetHashCode();
            var result = xHash.Equals(yHash);

            // Assert
            Assert.Equal(expected, result);
        }
Exemplo n.º 2
0
        public bool GetHashCodeTest(string xHead,
                                    string xTail,
                                    string yHead,
                                    string yTail)
        {
            // Arrange
            IPAddress xHeadAddress;

            if (!IPAddress.TryParse(xHead, out xHeadAddress))
            {
                xHeadAddress = null;
            }

            IPAddress xTailAddress;

            if (!IPAddress.TryParse(xTail, out xTailAddress))
            {
                xTailAddress = null;
            }

            IPAddress yHeadAddress;

            if (!IPAddress.TryParse(yHead, out yHeadAddress))
            {
                yHeadAddress = null;
            }

            IPAddress yTailAddress;

            if (!IPAddress.TryParse(yTail, out yTailAddress))
            {
                yTailAddress = null;
            }

            var xAddressRange = new IPAddressRange
            {
                Head = xHeadAddress,
                Tail = xTailAddress
            };

            var yAddressRange = new IPAddressRange
            {
                Head = yHeadAddress,
                Tail = yTailAddress
            };

            // Act
            var xHash = xAddressRange.GetHashCode();
            var yHash = yAddressRange.GetHashCode();

            // Assert
            return(xHash.Equals(yHash));
        }