public void Test(string value, string domainSpec, string ip4Cidr, string ip6Cidr) { Term term = _parser.Parse(string.Empty, Qualifier.Pass, value, (s, q, ds, dc) => new Mx(s, q, ds, dc)); A.CallTo(() => _domainSpecParser.Parse(domainSpec, false)).MustHaveHappenedOnceExactly(); A.CallTo(() => _dualCidrBlockParser.Parse(ip4Cidr, ip6Cidr)).MustHaveHappenedOnceExactly(); Assert.That(term, Is.Not.Null); }
public Term Parse(string mechanism, Qualifier qualifier, string arguments, Func <string, Qualifier, DomainSpec, DualCidrBlock, Term> termFactory) { string domainSpecString = string.Empty; string ip4CidrString = string.Empty; string ip6CidrString = string.Empty; if (!string.IsNullOrEmpty(arguments)) { Match match = _regex.Match(arguments); if (match.Success) { domainSpecString = match.Groups["domain_spec"].Value; ip4CidrString = match.Groups["ip4_cidr"].Value; ip6CidrString = match.Groups["ip6_cidr"].Value; } } DomainSpec domainSpec = _domainSpecParser.Parse(domainSpecString, false); DualCidrBlock dualCiderBlock = _dualCidrBlockParser.Parse(ip4CidrString, ip6CidrString); return(termFactory(mechanism, qualifier, domainSpec, dualCiderBlock)); }