public void HeadOverlappedBy_Test(bool expected,
                                          string thisHead,
                                          string thisTail,
                                          string thatHead,
                                          string thatTail)
        {
            // Arrange
            // this
            _ = IPAddress.TryParse(thisHead, out var thisHeadAddress);
            _ = IPAddress.TryParse(thisTail, out var thisTailAddress);

            var thisAddressRange = new IPAddressRange(thisHeadAddress, thisTailAddress);

            // that
            var thatAddressRange = IPAddress.TryParse(thatHead, out var thatHeadAddress) &&
                                   IPAddress.TryParse(thatTail, out var thatTailAddress)
                                    ? new IPAddressRange(thatHeadAddress, thatTailAddress)
                                    : null;

            // Act
            var result = thisAddressRange.HeadOverlappedBy(thatAddressRange);

            // Assert
            Assert.Equal(expected, result);
        }
Beispiel #2
0
        public bool HeadOverlappedByTest(string thisHead,
                                         string thisTail,
                                         string thatHead,
                                         string thatTail)
        {
            // Arrange
            // this
            IPAddress thisHeadAddress;

            if (!IPAddress.TryParse(thisHead, out thisHeadAddress))
            {
                thisHeadAddress = null;
            }

            IPAddress thisTailAddress;

            if (!IPAddress.TryParse(thisTail, out thisTailAddress))
            {
                thisTailAddress = null;
            }

            var thisAddressRange = new IPAddressRange
            {
                Head = thisHeadAddress,
                Tail = thisTailAddress
            };

            // that
            IPAddress thatHeadAddress;

            if (!IPAddress.TryParse(thatHead, out thatHeadAddress))
            {
                thatHeadAddress = null;
            }

            IPAddress thatTailAddress;

            if (!IPAddress.TryParse(thatTail, out thatTailAddress))
            {
                thatTailAddress = null;
            }

            var thatAddressRange = new IPAddressRange
            {
                Head = thatHeadAddress,
                Tail = thatTailAddress
            };

            // Act
            var result = thisAddressRange.HeadOverlappedBy(thatAddressRange);

            // Assert
            return(result);
        }