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); }
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); }
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); }