public void ShouldReturnBindingDoNothingIfValueIsNull() { var converter = new ByteArrayToStringConverter(); var result = converter.Convert(null, typeof(string), null, CultureInfo.CurrentCulture); result.Should().Be(Binding.DoNothing); }
public void Usage() { var converter = new ByteArrayToStringConverter(); var result = converter.Convert(new byte[] { 3, 5, 2, 77 }, typeof(string), null, CultureInfo.CurrentCulture); result.Should().Be("03-05-02-4D"); }
public void SetInitBytesRegister(string str) { var converter = new ByteArrayToStringConverter(); var array = converter.ConvertBack(str, typeof(string), null, CultureInfo.InvariantCulture) as byte[]; if (array == null || InitBytesRegister.Length != array.Length) { return; } InitBytesRegister = array; }
public void ByteArrayToStringConverterTest() { var conv = new ByteArrayToStringConverter(); var bytes = Convert.FromBase64String("SGVsbG8gd29ybGQ="); var bytesForward = conv.Convert(bytes, null, null, _cult) as string; Assert.AreEqual("Hello world", bytesForward); var bytesBack = conv.ConvertBack(bytesForward, null, null, _cult) as byte[]; CollectionAssert.AreEqual(bytes, bytesBack); }
public void ShouldThrowExceptionIfValueIfNotByteArray() { var converter = new ByteArrayToStringConverter(); Assert.Throws <NotSupportedException>(() => converter.Convert(3333, typeof(string), null, CultureInfo.CurrentCulture)); }