示例#1
0
        public void Test_FromString_EmptyBuffer(byte[] expected, string value)
        {
            var converter = new DefaultConverter();

            var buffer = new byte[0];

            converter.FromString(value, ref buffer, 0);

            Assert.Equal(expected, buffer);
        }
示例#2
0
        public void Test_FromString()
        {
#pragma warning disable 618
            var converter = new DefaultConverter();
#pragma warning restore 618
            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);
        }
示例#3
0
        public void Test_FromString(byte[] expected, string value, int offset)
        {
            var converter = new DefaultConverter();

            var buffer = new byte[32];

            converter.FromString(value, buffer, offset);

            // Buffer matches expected
            Assert.Equal(expected, buffer.Take(expected.Length));

            // Remainder of buffer is still zeroes
            Assert.All(buffer.Skip(expected.Length), p => Assert.Equal(0, p));
        }