public virtual void TestCharset() { NUnit.Framework.Assert.AreEqual("utf-8", DataUtil.GetCharsetFromContentType("text/html;charset=utf-8 ")); NUnit.Framework.Assert.AreEqual("UTF-8", DataUtil.GetCharsetFromContentType("text/html; charset=UTF-8")); NUnit.Framework.Assert.AreEqual("ISO-8859-1", DataUtil.GetCharsetFromContentType("text/html; charset=ISO-8859-1" )); NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType("text/html")); NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType(null)); NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType("text/html;charset=Unknown")); }
public virtual void TestQuotedCharset() { NUnit.Framework.Assert.AreEqual("utf-8", DataUtil.GetCharsetFromContentType("text/html; charset=\"utf-8\"" )); NUnit.Framework.Assert.AreEqual("UTF-8", DataUtil.GetCharsetFromContentType("text/html;charset=\"UTF-8\"") ); NUnit.Framework.Assert.AreEqual("ISO-8859-1", DataUtil.GetCharsetFromContentType("text/html; charset=\"ISO-8859-1\"" )); NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType("text/html; charset=\"Unsupported\"" )); NUnit.Framework.Assert.AreEqual("UTF-8", DataUtil.GetCharsetFromContentType("text/html; charset='UTF-8'")); }
public virtual void ShouldReturnNullForIllegalCharsetNames() { NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType("text/html; charset=$HJKDF§$/(")); }
public virtual void ShouldCorrectCharsetForDuplicateCharsetString() { NUnit.Framework.Assert.AreEqual("iso-8859-1", DataUtil.GetCharsetFromContentType("text/html; charset=charset=iso-8859-1" )); }
public virtual void ShouldSelectFirstCharsetOnWeirdMultileCharsetsInMetaTags() { NUnit.Framework.Assert.AreEqual("ISO-8859-1", DataUtil.GetCharsetFromContentType("text/html; charset=ISO-8859-1, charset=1251" )); }
public virtual void ShouldNotThrowExceptionOnEmptyCharset() { NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType("text/html; charset=")); NUnit.Framework.Assert.AreEqual(null, DataUtil.GetCharsetFromContentType("text/html; charset=;")); }