public void multiple_methods_are_rewritten()
        {
            var Xhtml = new XhtmlAnchor(null, null, () => Thread.CurrentPrincipal);
            var e =
                new InlineSharpViewElement(
                    () => Document.CreateElement<IAElement>().If(false).ID("hi").Class("hello")["content"]);

            e.OuterXml.ShouldBe(string.Empty);
        }
        public void an_if_evaluating_to_false_stops_the_rendering_of_methods_before_the_next_method_call()
        {
            var inlineEelement = new InlineSharpViewElement(
                () => Document.CreateElement<IDivElement>().If(false).ID("test"));

            inlineEelement.OuterXml.ShouldBe(string.Empty);
        }
 public void an_if_pointing_to_an_empty_string_generates_an_empty_element()
 {
     string value = string.Empty;
     var e = new InlineSharpViewElement(() => Document.CreateElement<IDivElement>().If(value));
     e.OuterXml.ShouldBe("<div></div>");
 }
        public void a_comparison_on_a_static_returning_false_results_in_an_empty_element()
        {
            var inlineEelement = new InlineSharpViewElement(
                () => Document.CreateElement<IDivElement>().If(Thread.CurrentPrincipal.Identity.Name == "john"));

            inlineEelement.OuterXml.ShouldBe(string.Empty);
        }
 public void access_to_a_null_field_that_is_an_interface_results_in_a_null_element()
 {
     IConvertible convertible = null;
     var e = new InlineSharpViewElement(() => Document.CreateElement<IDivElement>().If(convertible));
     e.OuterXml.ShouldBe(string.Empty);
 }
        public void current_in_if_is_rewritten()
        {

            var strings = new List<string> { "one", "two" };
            var e =
                new InlineSharpViewElement(
                    () => Document.CreateElement<IDivElement>().ForEach(strings)).If(strings.Current());
            e.OuterXml.ShouldBe("<div class=\"item\"></div>");
        }
        public void a_boolean_sets_to_false_results_in_an_empty_element()
        {
            bool result = false;
            var inlineEelement = new InlineSharpViewElement(
                () => Document.CreateElement<IDivElement>().If(result));

            inlineEelement.OuterXml.ShouldBe(string.Empty);
        }
        public void nested_foreach_clauses_are_rewritten()
        {
            var list = new List<string> { "one", "two" };
            var list2 = new List<string> { "three", "four" };

            var inlineElement = new InlineSharpViewElement(() =>
                Document.CreateElement<IDivElement>()
                        .Class(list.Current())
                        .ForEach(list)
                        [Document.CreateElement<IPElement>()
                                 .ID(list2.Current())
                                 .ForEach(list2)]
                );
            inlineElement.Prepare();
            inlineElement.OuterXml.ShouldBe("<div class=\"one\"><p id=\"three\"></p><p id=\"four\"></p></div><div class=\"two\"><p id=\"three\"></p><p id=\"four\"></p></div>");
        }
 public void the_foreach_is_not_executed_when_the_if_case_evaluates_to_false()
 {
     var strings = new List<string> {"one", "two"};
     var e =
         new InlineSharpViewElement(
             () => Document.CreateElement<IDivElement>().ForEach(strings).Class("item").If(false));
     e.OuterXml.ShouldBe(string.Empty);
 }
 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_child_scope_is_rewritten()
        {
            var list = new List<string> { "one", "two" };

            var inlineElement =
                new InlineSharpViewElement(() =>
                    Document.CreateElement<IDivElement>()
                        [Document.CreateElement<IDivElement>()
                                 .ID(list.Current())
                                 .ForEach(list)
                        ]);
            inlineElement.Prepare();
            inlineElement.OuterXml.ShouldBe("<div><div id=\"one\"></div><div id=\"two\"></div></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\" />");
 }
 public void a_foreach_applied_to_the_current_item_of_a_parent_foreach_are_processed()
 {
  Customer data = CreateCustomerOrderLines();
     var e = new InlineSharpViewElement(() => 
         Document.CreateElement<IDivElement>()
             .Class(data.Orders.Current().ProductName)
             .ForEach(data.Orders)
             [Document.CreateElement<IDivElement>()
                      .Class(data.Orders.Current().Lines.Current().Description)
                      .ForEach(data.Orders.Current().Lines)
         ]);
     e.OuterXml.ShouldBe(
         "<div class=\"product1\">"+
             "<div class=\"1\"></div>" +
             "<div class=\"2\"></div>" +
         "</div><div class=\"product2\">"+
             "<div class=\"1\"></div>" +
             "<div class=\"2\"></div>" +
         "</div>"
         );
 }
 public void a_foreach_and_multiple_current_items_producethe_correct_html_output()
 {
     var list = new List<string> {"one", "two"};
     var e = new InlineSharpViewElement(() => Document.CreateElement<IDivElement>().ForEach(list)
                                                  [
                                                  Document.CreateElement<IAElement>().Class(list.Current())[
                                                      list.Current()]
                                                  ]);
     e.OuterXml.ShouldBe("<div><a class=\"one\">one</a></div><div><a class=\"two\">two</a></div>");
 }
 public void both_sides_of_conditionals_inside_ifs_are_propagating_null_values()
 {
     var nested = new nested();
     string value = string.Empty;
     var inlineEelement = new InlineSharpViewElement(
         () => Document.CreateElement<IDivElement>().If(nested.subnested.booleanValue || false));
     inlineEelement.Prepare();
     inlineEelement.ChildNodes.Count.ShouldBe(0);
 }
 public void an_intermediate_null_value_results_in_a_null_element()
 {
     var nested = new nested();
     var inlineEelement = new InlineSharpViewElement(
         () => Document.CreateElement<IDivElement>().If(nested.subnested.property));
     inlineEelement.Prepare();
     inlineEelement.ChildNodes.Count.ShouldBe(0);
 }