Beispiel #1
0
 public void HasAttribute()
 {
     var tag = new Tag("div")
     {
         {"id", "foo"}
     };
     Assert.AreEqual("foo", tag["id"]);
     Assert.IsNull(tag[0]);
     Assert.AreEqual("<div id=\"foo\"></div>", tag.ToString());
 }
Beispiel #2
0
 public void HasChild()
 {
     var tag = new Tag("div")
     {
         new Tag("p")
         {
             "Hello World"
         }
     };
     Assert.IsInstanceOfType<Tag>(tag[0]);
     Assert.AreEqual("<div><p>Hello World</p></div>", tag.ToString());
 }
Beispiel #3
0
 public void HasAttributeAndChild()
 {
     var tag = new Tag("div")
     {
         {"id", "foo"},
         new Tag("p")
         {
             "Hello World"
         }
     };
     Assert.AreEqual("foo", tag["id"]);
     Assert.AreEqual("<div id=\"foo\"><p>Hello World</p></div>", tag.ToString());
 }
Beispiel #4
0
 public void HasNormalAttributesWithSameName()
 {
     var tag = new Tag("div")
     {
         {"id", "foo"},
         {"id", "bar"}
     };
     Assert.AreEqual("bar", tag["id"]);
 }
Beispiel #5
0
 public void HasListAttributesWithSameName()
 {
     var tag = new Tag("div")
     {
         {"class", "foo"},
         {"class", "bar"}
     };
     Assert.AreEqual("foo bar", tag["class"]);
 }
Beispiel #6
0
        public void UsesDictionary()
        {
            var attributes = new Dictionary<string, string>{
                {"id", "foo"}, {"class", "bar"}
            };

            var tag = new Tag("div")
            {
                attributes
            };

            Assert.AreEqual("foo", tag["id"]);
            Assert.AreEqual("bar", tag["class"]);
        }
Beispiel #7
0
        public void UsesAnonymousTypeWithCasing()
        {
            var tag = new Tag("div")
            {
                new { Id = "foo", Class = "bar" }
            };

            Assert.AreEqual("foo", tag["id"]);
            Assert.AreEqual("bar", tag["class"]);
        }
Beispiel #8
0
        public void UsesAnonymousType()
        {
            var tag = new Tag("div")
            {
                new  { id = "foo" }
            };

            Assert.AreEqual("foo", tag["id"]);
        }
Beispiel #9
0
 public void IsEmpty()
 {
     var tag = new Tag("div");
     Assert.IsNull(tag[0]);
     Assert.AreEqual("<div></div>", tag.ToString());
 }
Beispiel #10
0
 public void HasText()
 {
     var tag = new Tag("p")
     {
         "Hello World"
     };
     Assert.IsInstanceOfType<Tag>(tag[0]);
     Assert.AreEqual("<p>Hello World</p>", tag.ToString());
 }