public void FromHexTest() { for (int i = 0; i <= byte.MaxValue; i++) { byte b = (byte)i; string hexByte = b.ToHex(); byte actual = ByteExtensions.FromHex(hexByte); Assert.AreEqual(b, actual, b.ToString()); } Assert.AreEqual(ByteExtensions.FromHex(null), 0); Assert.AreEqual(ByteExtensions.FromHex(""), 0); Assert.AreEqual(ByteExtensions.FromHex("abc"), 0); Assert.AreEqual(ByteExtensions.FromHex("ge"), 0); Assert.AreEqual(ByteExtensions.FromHex("çá"), 0); Assert.AreEqual(ByteExtensions.FromHex("=="), 0); Assert.AreEqual(ByteExtensions.FromHex("="), 0); Assert.AreEqual(ByteExtensions.FromHex("m"), 0); Assert.AreEqual(ByteExtensions.FromHex("a"), 10); }