public void ConvertToValidUnicode() { string validUnicodeHex = "00D6"; string result = ParserUtils.ConvertToUnicode(validUnicodeHex); Assert.AreEqual("\u00D6", result); validUnicodeHex = "FFFE"; result = ParserUtils.ConvertToUnicode(validUnicodeHex); Assert.AreEqual("\uFFFE", result); validUnicodeHex = "FEFF"; result = ParserUtils.ConvertToUnicode(validUnicodeHex); Assert.AreEqual("\uFEFF", result); validUnicodeHex = string.Empty; result = ParserUtils.ConvertToUnicode(validUnicodeHex); Assert.AreEqual(string.Empty, result); }
public void ConvertToInvalidUnicode() { string invalidUnicodeHex = "asdf"; Assert.Throws <FormatException>(() => ParserUtils.ConvertToUnicode(invalidUnicodeHex)); invalidUnicodeHex = "as"; Assert.Throws <FormatException>(() => ParserUtils.ConvertToUnicode(invalidUnicodeHex)); invalidUnicodeHex = ".aft"; Assert.Throws <FormatException>(() => ParserUtils.ConvertToUnicode(invalidUnicodeHex)); }