public void Test_ToByte() { var converter = new ManualByteConverter(); var actual = converter.ToByte(_buffer, 0); const int expected = 128; Assert.AreEqual(expected, actual); }
public void Test_ToInt32() { var converter = new ManualByteConverter(); var actual = converter.ToInt32(_buffer, 8); const uint expected = 5u; Assert.AreEqual(expected, actual); }
public void Test_FromString() { var converter = new ManualByteConverter(); var buffer = new byte[Encoding.UTF8.GetByteCount("Hello")]; converter.FromString("Hello", buffer, 0); var expected = new byte[]{0x48, 0x65, 0x6c, 0x6c, 0x6f}; Assert.AreEqual(expected, buffer); }
public void Test_ToString() { const int offset = 24; const int length = 5; var converter = new ManualByteConverter(); var actual = converter.ToString(_buffer, offset, length); const string expected = "Hello"; Assert.AreEqual(expected, actual); }
public void Test_FromUInt64() { var converter = new ManualByteConverter(); var actual = new byte[15]; converter.FromUInt64(5, actual, 3); var expected = new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00 }; Assert.AreEqual(expected, actual); }