Ejemplo n.º 1
0
 private string Begin(TestTag tag, ElementData data)
 {
     using (StringWriter writer = new StringWriter())
     {
         tag.Begin(writer, data);
         return(writer.ToString());
     }
 }
Ejemplo n.º 2
0
            public void OpeningTag()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper);

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div>" + Environment.NewLine);
            }
Ejemplo n.º 3
0
            public void AttributeEncodesQuotes()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Attribute("foo", "b\"ar");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div foo=\"b&quot;ar\">" + Environment.NewLine);
            }
Ejemplo n.º 4
0
            public void StyleEndWithSemicolon()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Style("foo", "bar;");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div style=\"foo:bar;\">" + Environment.NewLine);
            }
Ejemplo n.º 5
0
            public void DuplicateClass()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Class("foo", "bar", "foo");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div class=\"bar foo\">" + Environment.NewLine);
            }
Ejemplo n.º 6
0
            public void MultipleAttributes()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Attribute("foo", "bar")
                                   .Attribute("fizz", "buzz");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div fizz=\"buzz\" foo=\"bar\">" + Environment.NewLine);
            }
Ejemplo n.º 7
0
            public void MixedStylesWithSemicolon()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Attribute("style", "foo: bar;")
                                   .Style("fizz", "buzz");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div style=\"foo: bar;fizz:buzz;\">" + Environment.NewLine);
            }
Ejemplo n.º 8
0
            public void MultipleStyles()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Style("foo", "bar")
                                   .Style("fizz", "buzz");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div style=\"fizz:buzz;foo:bar;\">" + Environment.NewLine);
            }
Ejemplo n.º 9
0
            public void MergeClasses()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Class("foo", "bar")
                                   .Attribute("class", "fizz buzz bar");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div class=\"bar buzz fizz foo\">" + Environment.NewLine);
            }
Ejemplo n.º 10
0
            public void StylesAndClasses()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper)
                                   .Style("a", "b")
                                   .Style("c", "d")
                                   .Class("foo")
                                   .Class("bar");

                // When
                string output = Begin(tag, data);

                // Then
                output.ShouldBe("<div class=\"bar foo\" style=\"a:b;c:d;\">" + Environment.NewLine);
            }
Ejemplo n.º 11
0
            public void NoClosingTagIfEmptyElement()
            {
                // Given
                TestTag     tag  = new TestTag("div", true);
                ElementData data = new ElementData(tag.Helper);

                // When
                string output;

                using (StringWriter writer = new StringWriter())
                {
                    tag.End(writer, data);
                    output = writer.ToString();
                }

                // Then
                output.ShouldBeEmpty();
            }
Ejemplo n.º 12
0
            public void ClosingTag()
            {
                // Given
                TestTag     tag  = new TestTag("div");
                ElementData data = new ElementData(tag.Helper);

                // When
                string output;

                using (StringWriter writer = new StringWriter())
                {
                    tag.End(writer, data);
                    output = writer.ToString();
                }

                // Then
                output.ShouldBe("</div>" + Environment.NewLine);
            }