Exemplo n.º 1
0
        public void SerializeOK()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new StreamConfig();
            var serdes           = new MockAvroSerDes(mockSchemaClient);

            serdes.Initialize(new Net.SerDes.SerDesContext(config));
            var person = new Person {
                age = 18, firstName = "TEST", lastName = "TEST"
            };
            var bytes = serdes.Serialize(person, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Value, topic));

            Assert.IsNotNull(bytes);
            Assert.IsTrue(bytes.Length > 0);
        }
Exemplo n.º 2
0
        public void DeserializeOK()
        {
            var mockSchemaClient = new MockSchemaRegistryClient();
            var config           = new StreamConfig();
            var serdes           = new MockAvroSerDes(mockSchemaClient);

            serdes.Initialize(new Net.SerDes.SerDesContext(config));
            var person = new Person {
                age = 18, firstName = "TEST", lastName = "TEST"
            };
            var bytes = serdes.Serialize(person, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Value, topic));
            var pbis  = serdes.Deserialize(bytes, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Value, topic));

            Assert.AreEqual(18, pbis.age);
            Assert.AreEqual("TEST", pbis.firstName);
            Assert.AreEqual("TEST", pbis.lastName);
        }