public void testNestedNodesWithList() { HtmlElement td = new HtmlElement("td", "test"); HtmlElement td2 = new HtmlElement("td", "test2"); HtmlElement tr = new HtmlElement("tr", new List<HtmlElement>(){ td, td2 }); Assert.AreEqual("<tr><td>test</td><td>test2</td></tr>", tr.Build()); }
public void testAppendListOfElements() { HtmlElement td = new HtmlElement("td", "test"); HtmlElement td2 = new HtmlElement("td", "test2"); var lst = new List<HtmlElement>() {td, td2}; HtmlElement tr = new HtmlElement("tr"); tr.Append(lst); Assert.AreEqual("<tr><td>test</td><td>test2</td></tr>", tr.Build()); }
public void testNestedNodesWithAppend() { HtmlElement table = new HtmlElement("table"); HtmlElement td = new HtmlElement("td", "test"); HtmlElement td2 = new HtmlElement("td", "test2"); HtmlElement tr = new HtmlElement("tr", new List<HtmlElement>() { td, td2 }); table = table.Append(tr); Assert.AreEqual("<table><tr><td>test</td><td>test2</td></tr></table>", table.Build()); }
public void testAnoymousFunc() { var table = new HtmlElement("table", new Dictionary<string, string>() {{"width", "100%"}}) .Append( ()=> new HtmlElement("tr") .Append(new HtmlElement("td", "test", new Dictionary<string, string>() {{"class", "my-class"}})) .Append(new HtmlElement("td", "test2", new Dictionary<string, string>() {{"class", "my-class"}})) ); Assert.AreEqual("<table width='100%' ><tr><td class='my-class' >test</td><td class='my-class' >test2</td></tr></table>", table.Build()); }
public void testAttributes() { var attrs = new Dictionary<String, String>() { {"class", "my-class and-another"}, {"ng-value", "blah"} }; HtmlElement td = new HtmlElement("td", attrs); Assert.AreEqual("<td class='my-class and-another' ng-value='blah' ></td>", td.Build()); }
private Dictionary<string, object> SetConfirmationMergeData(int parentEventId, IEnumerable<int> kids) { var parentEvent = _eventService.GetEvent(parentEventId); var kidList = kids.Select(kid => _contactService.GetContactByParticipantId(kid)).Select(contact => contact.First_Name + " " + contact.Last_Name).ToList(); var html = new HtmlElement("ul"); var elements = kidList.Select(kid => new HtmlElement("li", kid)); foreach (var htmlElement in elements) { html.Append(htmlElement); } var mergeData = new Dictionary<string, object> { {"EventTitle", parentEvent.EventTitle}, {"EventStartDate", parentEvent.EventStartDate.ToString("g")}, {"ChildNames", html.Build()} }; return mergeData; }
public void testTextNode() { HtmlElement td = new HtmlElement("td", "test"); Assert.AreEqual(td.Build(), "<td>test</td>"); }
public void testBasicHtmlElement() { HtmlElement table = new HtmlElement("table"); Assert.AreEqual(table.Build(), "<table></table>"); }
private String ChildcareData(IList<Participant> children) { var el = new HtmlElement("span", new Dictionary<string, string>(), "You have indicated that you need childcare for the following children:") .Append(new HtmlElement("ul").Append(children.Select(child => new HtmlElement("li", child.DisplayName)).ToList())); return el.Build(); }