public void BaseConvertersTest(bool reverse) { var str = "Hello my friend"; var stringResult = _bitConverterHelper.ConvertToBytes(str, typeof(string), reverse); var stringResultBack = _bitConverterHelper.ConvertFromBytes(new ReadOnlySequence <byte>(stringResult), typeof(string), reverse); Assert.AreEqual(str, stringResultBack); var datetime = DateTime.Now; var dateTimeResult = _bitConverterHelper.ConvertToBytes(datetime, typeof(DateTime), reverse); var dateTimeResultBack = _bitConverterHelper.ConvertFromBytes(new ReadOnlySequence <byte>(dateTimeResult), typeof(DateTime), reverse); Assert.AreEqual(datetime, dateTimeResultBack); var guid = Guid.NewGuid(); var guidResult = _bitConverterHelper.ConvertToBytes(guid, typeof(Guid), reverse); var guidResultBack = _bitConverterHelper.ConvertFromBytes(new ReadOnlySequence <byte>(guidResult), typeof(Guid), reverse); Assert.AreEqual(guid, guidResultBack); }
public void BitConverterFromBytesTest(byte[] bytes, Type type, bool reverse) { var converter = new BitConverterHelper(new TcpClientIoOptions()); Assert.That(converter.ConvertFromBytes(new ReadOnlySequence <byte>(bytes), type, reverse).GetType() == type, "converter.ConvertFromBytes(bytes, type, reverse).GetType() == type"); }