private static IHtmlElement CreateElement(Match match) { var element = new HtmlElement { TagName = match.Groups["tagName"].Value, InnerHtml = match.Groups["innerHtml"].Value }; var attributeMatches = GetAttributeMatches(match); SetAttributes(element, attributeMatches); return element; }
public void First_for_empty_collection_should_get_empty_element() { var expectedElement = new HtmlElement { TagName = "", InnerHtml = "" }; var elements = new IHtmlElement[] { }; var collection = new HtmlCollection(elements); Assert.That(collection.First, Is.EqualTo(new HtmlElement()) .Using(new HtmlElementEqualityComparer())); }
private static void SetAttributes(HtmlElement element, MatchCollection matches) { foreach (Match match in matches) element.SetAttribute(match.Groups["name"].Value, match.Groups["value"].Value); }