Ejemplo n.º 1
0
        public void DecodeMessageShouldThrowWhenCrcFails()
        {
            var testMessage = new Message(value: "kafka test message.", key: "test");

            using (var writer = new KafkaWriter())
            {
                testMessage.WriteTo(writer);
                var encoded = writer.ToSegment(false);
                encoded.Array[encoded.Offset] += 1;
                using (var reader = new KafkaReader(encoded))
                {
                    Assert.Throws <CrcValidationException>(() => reader.ReadMessage(encoded.Count, 0).First());
                }
            }
        }
Ejemplo n.º 2
0
        public void EnsureMessageEncodeAndDecodeAreCompatible(string key, string value)
        {
            var testMessage = new Message(key: key, value: value);

            using (var writer = new KafkaWriter())
            {
                testMessage.WriteTo(writer);
                var encoded = writer.ToSegment(false);
                using (var reader = new KafkaReader(encoded))
                {
                    var result = reader.ReadMessage(encoded.Count, 0).First();

                    Assert.That(testMessage.Key, Is.EqualTo(result.Key));
                    Assert.That(testMessage.Value, Is.EqualTo(result.Value));
                }
            }
        }