public void ConvUtils_ToByte() { Assert.AreEqual((byte)55, ConvUtils.ToByteEx("55"), "Result differs"); Assert.AreEqual((byte)0x55, ConvUtils.ToByteEx("0x55"), "Result differs"); Assert.AreEqual((byte)0x55, ConvUtils.ToByteEx("0X55"), "Result differs"); Assert.AreEqual((byte)3, ConvUtils.ToByteEx("0b11"), "Result differs"); Assert.AreEqual((byte)5, ConvUtils.ToByteEx("0B101"), "Result differs"); Assert.AreEqual((byte)0xFE, ConvUtils.ToByteEx("0XFE"), "Result differs"); byte?nres; nres = ConvUtils.ToNullableByteEx(null); Assert.IsNull(nres, "Not null result"); nres = ConvUtils.ToNullableByteEx(String.Empty); Assert.IsNull(nres, "Not null result"); nres = ConvUtils.ToNullableByteEx(""); Assert.IsNull(nres, "Not null result"); nres = ConvUtils.ToNullableByteEx("0xAA"); Assert.AreEqual((byte)0xAAU, nres, "Result differs"); Assert.Throws <OverflowException>(() => ConvUtils.ToByteEx("0xFFF")); Assert.Throws <OverflowException>(() => ConvUtils.ToByteEx("-1")); }