예제 #1
0
        public void TestWithoutErrors(string ipString)
        {
            Ip6Addr ip6Addr = _parser.Parse(ipString);

            Assert.That(ip6Addr.Value, Is.EqualTo(ipString));
            Assert.That(ip6Addr.ErrorCount, Is.EqualTo(0));
        }
예제 #2
0
        public void Test(string ipString, int errorCount, string errorStringPattern)
        {
            Ip6Addr ip6Addr = _parser.Parse(ipString);

            Assert.That(ip6Addr.Value, Is.EqualTo(ipString));
            Assert.That(ip6Addr.ErrorCount, Is.EqualTo(errorCount));
            Assert.That((ip6Addr.Errors.FirstOrDefault()?.Message ?? string.Empty).Contains(errorStringPattern), Is.True);
        }
예제 #3
0
        public void TestWithErrors(string ipString, string errorStringPattern)
        {
            Ip6Addr ip6Addr = _parser.Parse(ipString);

            Assert.That(ip6Addr.Value, Is.EqualTo(ipString));
            Assert.That(ip6Addr.ErrorCount, Is.EqualTo(1));
            Assert.That(ip6Addr.Errors[0].Message.Contains(errorStringPattern), Is.True);
        }
예제 #4
0
        //"ip6" ":" ip6-network [ ip6-cidr-length ]
        public Term Parse(string mechanism, Qualifier qualifier, string arguments)
        {
            string[] splits = arguments.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            Ip6Addr ipAddress = _ip6AddrParser.Parse(splits.ElementAtOrDefault(0));

            Ip6CidrBlock cidrBlock = _cidrBlockParser.Parse(splits.ElementAtOrDefault(1));

            return(new Ip6(mechanism, qualifier, ipAddress, cidrBlock));
        }
        public Ip6Addr Parse(string ipAddressString)
        {
            Ip6Addr   ip6Addr = new Ip6Addr(ipAddressString);
            IPAddress ipAddress;

            if (IPAddress.TryParse(ipAddressString, out ipAddress))
            {
                if (ipAddress.AddressFamily != AddressFamily.InterNetworkV6)
                {
                    string errorMessage = string.Format(SpfParserResource.InvalidValueErrorMessage, "ipv6 address", ipAddressString);
                    ip6Addr.AddError(new Error(ErrorType.Error, errorMessage));
                }
            }
            else
            {
                string errorMessage = string.Format(SpfParserResource.InvalidValueErrorMessage, "ip address", ipAddressString);
                ip6Addr.AddError(new Error(ErrorType.Error, errorMessage));
            }
            return(ip6Addr);
        }