예제 #1
0
        public void Incompatible()
        {
            var avroSerializer   = new AsyncAvroSerializer <string>(schemaRegistryClient);
            var avroDeserializer = new AsyncAvroDeserializer <int>(schemaRegistryClient);
            var bytes            = avroSerializer.SerializeAsync("hello world", new SerializationContext(MessageComponentType.Value, testTopic)).Result;

            Assert.Throws <System.AggregateException>(() => avroDeserializer.DeserializeAsync(bytes, false, new SerializationContext(MessageComponentType.Value, testTopic)).Result);
        }
예제 #2
0
        public void DoubleSerDe()
        {
            var avroSerializer   = new AsyncAvroSerializer <double>(schemaRegistryClient);
            var avroDeserializer = new AsyncAvroDeserializer <double>(schemaRegistryClient);

            byte[] bytes;
            bytes = avroSerializer.SerializeAsync(123d, new SerializationContext(MessageComponentType.Value, testTopic)).Result;
            Assert.Equal(123d, avroDeserializer.DeserializeAsync(bytes, false, new SerializationContext(MessageComponentType.Value, testTopic)).Result);
        }
예제 #3
0
        public void ISpecificRecord()
        {
            var serializer   = new AsyncAvroSerializer <User>(schemaRegistryClient);
            var deserializer = new AsyncAvroDeserializer <User>(schemaRegistryClient);

            var user = new User
            {
                favorite_color  = "blue",
                favorite_number = 100,
                name            = "awesome"
            };

            var bytes  = serializer.SerializeAsync(user, new SerializationContext(MessageComponentType.Value, testTopic)).Result;
            var result = deserializer.DeserializeAsync(bytes, false, new SerializationContext(MessageComponentType.Value, testTopic)).Result;

            Assert.Equal(user.name, result.name);
            Assert.Equal(user.favorite_color, result.favorite_color);
            Assert.Equal(user.favorite_number, result.favorite_number);
        }