Пример #1
0
        public void Ctor_HtmlDoctypeType(HtmlDoctypeType doctype, string expectedDoctype)
        {
            HtmlDoctype htmlDoctype = new HtmlDoctype(doctype);

            Assert.Equal(expectedDoctype, htmlDoctype.Doctype);
            Assert.Equal(doctype, htmlDoctype.DoctypeType);
        }
Пример #2
0
        public void Ctor_String(string doctype, HtmlDoctypeType expectedDoctypeType)
        {
            HtmlDoctype htmlDoctype = new HtmlDoctype(doctype);

            Assert.Equal(doctype, htmlDoctype.Doctype);
            Assert.Equal(expectedDoctypeType, htmlDoctype.DoctypeType);
        }
Пример #3
0
        public HtmlDoctype(HtmlDoctypeType doctype)
        {
            if (doctype == HtmlDoctypeType.Html5)
            {
                Doctype = "DOCTYPE html";
            }
            else if (doctype == HtmlDoctypeType.Html401Strict)
            {
                Doctype = "DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"";
            }
            else if (doctype == HtmlDoctypeType.Html401Transitional)
            {
                Doctype = "DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"";
            }
            else if (doctype == HtmlDoctypeType.Html401Frameset)
            {
                Doctype = "DOCTYPE HTML PUBLIC \" -//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\"";
            }
            else if (doctype == HtmlDoctypeType.XHtml10Strict)
            {
                Doctype = "DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"";
            }
            else if (doctype == HtmlDoctypeType.XHtml10Transitional)
            {
                Doctype = "DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"";
            }
            else if (doctype == HtmlDoctypeType.XHtml10Frameset)
            {
                Doctype = "DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\"";
            }
            else if (doctype == HtmlDoctypeType.XHtml11)
            {
                Doctype = "DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"";
            }
            else
            {
                throw new ArgumentException("Can't infer the doctype from the HtmlDoctypeType provided.", nameof(doctype));
            }

            _doctypeType = doctype;
        }
Пример #4
0
 public void Ctor_NotSupportedHtmlDoctypeType_ThrowsArgumentException(HtmlDoctypeType doctype)
 {
     Assert.Throws <ArgumentException>("doctype", () => new HtmlDoctype(doctype));
 }
Пример #5
0
 public void Ctor_String(string doctype, HtmlDoctypeType expectedDoctypeType)
 {
     HtmlDoctype htmlDoctype = new HtmlDoctype(doctype);
     Assert.Equal(doctype, htmlDoctype.Doctype);
     Assert.Equal(expectedDoctypeType, htmlDoctype.DoctypeType);
 }
Пример #6
0
 public void Ctor_NotSupportedHtmlDoctypeType_ThrowsArgumentException(HtmlDoctypeType doctype)
 {
     Assert.Throws<ArgumentException>("doctype", () => new HtmlDoctype(doctype));
 }
Пример #7
0
 public void Ctor_HtmlDoctypeType(HtmlDoctypeType doctype, string expectedDoctype)
 {
     HtmlDoctype htmlDoctype = new HtmlDoctype(doctype);
     Assert.Equal(expectedDoctype, htmlDoctype.Doctype);
     Assert.Equal(doctype, htmlDoctype.DoctypeType);
 }