public void nested_foreach_respect_the_index_values() { var anchor = new XhtmlAnchor(null, null, () => null); Customer data = CreateCustomerOrderLines(); var e = new InlineSharpViewElement(() => Document.CreateElement <IDivElement>().ForEach(data.Orders)[ anchor.TextBox(() => data.Orders.Current().Lines.Current().Description).ForEach(data.Orders.Current().Lines) ]); var elementString = e.OuterXml; elementString.ShouldBe( "<div>" + "<input type=\"text\" name=\"Customer.Orders:0.Lines:0.Description\" value=\"1\" />" + "<input type=\"text\" name=\"Customer.Orders:0.Lines:1.Description\" value=\"2\" />" + "</div><div>" + "<input type=\"text\" name=\"Customer.Orders:1.Lines:0.Description\" value=\"1\" />" + "<input type=\"text\" name=\"Customer.Orders:1.Lines:1.Description\" value=\"2\" />" + "</div>"); }
public void a_foreach_and_multiple_current_items_produce_the_correct_html_output1() { var anchor = new XhtmlAnchor(null, null, () => null); var data = new Customer { Orders = new List <Order> { new Order { ProductName = "product1" }, new Order { ProductName = "product2" } } }; var e = new InlineSharpViewElement(() => anchor.TextBox(() => data.Orders.Current().ProductName).ForEach(data.Orders)); e.OuterXml.ShouldBe("<input type=\"text\" name=\"Customer.Orders:0.ProductName\" value=\"product1\" />" + "<input type=\"text\" name=\"Customer.Orders:1.ProductName\" value=\"product2\" />"); }