public void FindByAttributeNameTest() { HtmlElement root = new HtmlElement("root"); HtmlNodeCollection target = new HtmlNodeCollection(root); target.Add(new HtmlElement("first")); target.Add(new HtmlElement("second")); target.Add(new HtmlElement("third")); ((HtmlElement)target[0]).Nodes.Add(new HtmlElement("secondchild")); ((HtmlElement)target[1]).Attributes.Add(new HtmlAttribute("firstattribute")); ((HtmlElement)target[1]).Attributes.Add(new HtmlAttribute("secondattribute")); ((HtmlElement)target[2]).Attributes.Add(new HtmlAttribute("firstattribute")); Assert.AreEqual(target.FindByAttributeName("firstattribute").Count, 2); ((HtmlElement)((HtmlElement)target[0]).Nodes[0]).Attributes.Add(new HtmlAttribute("firstattribute")); Assert.AreEqual(target.FindByAttributeName("firstattribute", false).Count, 2); Assert.AreEqual(target.FindByAttributeName("firstattribute", true).Count, 3); }