コード例 #1
0
        public void Int16Tests(Int16 number, Byte[] expectedBytes)
        {
            // arrange
            var memoryStream = new MemoryStream();
            var binaryWriter = new BigEndianBinaryWriter(memoryStream);

            // act
            binaryWriter.Write(number);

            // assert
            var actualBytes = memoryStream.ToArray();
            Assert.That(expectedBytes, Is.EqualTo(actualBytes));
        }
コード例 #2
0
        public void WhenMessageIsTruncatedThenBufferUnderRunExceptionIsThrown()
        {
            // arrange
            var offset = (Int64)0;
            var message = new Byte[] { };
            var messageSize = message.Length + 1;
            var memoryStream = new MemoryStream();
            var binaryWriter = new BigEndianBinaryWriter(memoryStream);
            binaryWriter.Write(offset);
            binaryWriter.Write(messageSize);
            binaryWriter.Write(message);
            var payloadBytes = memoryStream.ToArray();

            // act/assert
            Assert.Throws<BufferUnderRunException>(() => Message.DecodeMessageSet(payloadBytes).ToList());
        }
コード例 #3
0
 public KafkaMessagePacker()
 {
     _stream = new BigEndianBinaryWriter(new MemoryStream());
     Pack(IntegerByteSize); //pre-allocate space for buffer length
 }
コード例 #4
0
 public KafkaMessagePacker()
 {
     _stream = new BigEndianBinaryWriter(new MemoryStream());
     Pack(IntegerByteSize); //pre-allocate space for buffer length
 }
コード例 #5
0
        public void CharSubArrayTests(Char[] value, Int32 index, Int32 count, Byte[] expectedBytes)
        {
            // arrange
            var memoryStream = new MemoryStream();
            var binaryWriter = new BigEndianBinaryWriter(memoryStream);

            // act
            binaryWriter.Write(value, index, count);

            // assert
            var actualBytes = memoryStream.ToArray();
            Assert.That(expectedBytes, Is.EqualTo(actualBytes));
        }
コード例 #6
0
        public void StringTests(String value, Byte[] expectedBytes, StringPrefixEncoding encoding)
        {

            // arrange
            var memoryStream = new MemoryStream();
            var binaryWriter = new BigEndianBinaryWriter(memoryStream);

            // act
            binaryWriter.Write(value, encoding);

            // assert
            var actualBytes = memoryStream.ToArray();
            Assert.That(expectedBytes, Is.EqualTo(actualBytes));
        }
コード例 #7
0
 public void StringNotSupportedTest()
 {
     // arrange
     var memoryStream = new MemoryStream();
     var binaryWriter = new BigEndianBinaryWriter(memoryStream);
     binaryWriter.Write("test");
 }