public void ConvertBack_Normal_NullInputReturnsNull()
 {
     IValueConverter converter = new BytesToHexConverter();
     object input = null;
     byte[] expected = null;
     byte[] output = (byte[])converter.ConvertBack(input, typeof(byte[]), null, Thread.CurrentThread.CurrentCulture);
     Assert.AreEqual(expected, output, string.Format("Expected result is '{0}'", expected));
 }
 public void ConvertBack_Normal_StringToHex()
 {
     IValueConverter converter = new BytesToHexConverter();
     object input = "0x0102030405060708090A0B0C0D0E0F10204080FF";
     byte[] expected = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64, 128, 255 };
     byte[] output = (byte[])converter.ConvertBack(input, typeof(byte[]), null, Thread.CurrentThread.CurrentCulture);
     Assert.AreEqual(expected.Length, output.Length);
     for (int i = 0; i < expected.Length; i++)
     {
         Assert.AreEqual(expected[i], output[i]);
     }
 }
 public void ConvertBack_Erroneous_InvalidTargetTypeThrowsArgumentException()
 {
     BytesToHexConverter converter = new BytesToHexConverter();
     object input = "0x02";
     object output = converter.ConvertBack(input, typeof(DateTime), null, Thread.CurrentThread.CurrentCulture);
 }
 public void ConvertBack_Erroneous_NoLeading0xFormatException()
 {
     BytesToHexConverter converter = new BytesToHexConverter();
     object input = "020408FF";
     object output = converter.ConvertBack(input, typeof(byte[]), null, Thread.CurrentThread.CurrentCulture);
 }
 public void ConvertBack_Erroneous_PartiallyValidFormatThrowsFormatException()
 {
     BytesToHexConverter converter = new BytesToHexConverter();
     object input = "0x020408_FAIL_";
     object output = converter.ConvertBack(input, typeof(byte[]), null, Thread.CurrentThread.CurrentCulture);
 }
 public void ConvertBack_Erroneous_InvalidFormatThrowsFormatException()
 {
     BytesToHexConverter converter = new BytesToHexConverter();
     object input = "Invalid string";
     object output = converter.ConvertBack(input, typeof(byte[]), null, Thread.CurrentThread.CurrentCulture);
 }