public static bool TryCreate(string webAddress, out WebAddress result, out string failureReason) { var specification = new WebAddressSpecification(); if (specification.IsSatisfiedBy(webAddress)) { result = new WebAddress(webAddress); failureReason = string.Empty; return true; } result = null; failureReason = specification.GetReasonsForDissatisfactionSeparatedWithNewLine(); return false; }
public static WebAddress Create(string webAddress) { if (webAddress == null) { throw new ArgumentNullException("webAddress"); } var specification = new WebAddressSpecification(); if (specification.IsSatisfiedBy(webAddress)) { return new WebAddress(webAddress); } throw new ArgumentException(string.Format("Web address '{0}' doesn't satisfy specification.", webAddress), "webAddress"); }
private static void AssertSatisfiedSpecification(string value) { var specification = new WebAddressSpecification(); Assert.IsTrue(specification.IsSatisfiedBy(value)); Assert.IsTrue(string.IsNullOrWhiteSpace(specification.GetReasonsForDissatisfactionSeparatedWithNewLine())); }