Пример #1
0
        public void Appends_String()
        {
            var expectedResult = new byte[] {
                0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
                0x00, 0x01, 0x36, 0x16
            };
            var builder = new PduWriter();

            builder.WriteString("Hello");
            builder.WriteInteger(79382);
            var buffer = builder.GetBytes();

            CollectionAssert.AreEqual(expectedResult, buffer);
        }
Пример #2
0
        public void Writes_Null_String()
        {
            var expectedResult = new byte[] { 0x00 };
            var builder = new PduWriter();

            builder.WriteString(null);
            var buffer = builder.GetBytes();

            CollectionAssert.AreEqual(expectedResult, buffer);
        }
Пример #3
0
        public void Writes_Null_Terminated_String()
        {
            var expectedResult = new byte[] {
                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x00
            };
            var builder = new PduWriter();

            builder.WriteString("abcdefgh");
            var buffer = builder.GetBytes();

            CollectionAssert.AreEqual(expectedResult, buffer);
        }
Пример #4
0
        public void Resizes_Buffer_On_Write_String()
        {
            var expectedResult = new byte[] {
                0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x00,
            };
            var builder = new PduWriter(0);
            builder.WriteString("Hello");
            var buffer = builder.GetBytes();

            CollectionAssert.AreEqual(expectedResult, buffer);
        }