public void StringSerDe() { var avroSerializer = new AvroSerializer <string>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, object>(), false); var avroDeserializer = new AvroDeserializer <string>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, object>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, "abc"); Assert.Equal("abc", avroDeserializer.Deserialize(testTopic, bytes)); }
public void BytesSerDe() { var avroSerializer = new AvroSerializer <byte[]>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, object>(), false); var avroDeserializer = new AvroDeserializer <byte[]>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, object>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, new byte[] { 2, 3, 4 }); Assert.Equal(new byte[] { 2, 3, 4 }, avroDeserializer.Deserialize(testTopic, bytes)); }
public void Incompatible() { var avroSerializer = new AvroSerializer <string>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, object>(), false); var avroDeserializer = new AvroDeserializer <int>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, object>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, "Hello world"); Assert.Throws <global::Avro.AvroException>(() => avroDeserializer.Deserialize(testTopic, bytes)); }
public void DoubleSerDe() { var avroSerializer = new AvroSerializer <double>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, object>(), false); var avroDeserializer = new AvroDeserializer <double>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, object>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, 123d); Assert.Equal(123d, avroDeserializer.Deserialize(testTopic, bytes)); }
public void BoolSerDe() { var avroSerializer = new AvroSerializer <bool>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, string>(), false); var avroDeserializer = new AvroDeserializer <bool>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, string>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, true); Assert.Equal(true, avroDeserializer.Deserialize(testTopic, bytes, false)); }
public void NullSerDe() { var avroSerializer = new AvroSerializer <Null>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, string>(), false); var avroDeserializer = new AvroDeserializer <Null>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, string>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, null); Assert.Null(avroDeserializer.Deserialize(testTopic, bytes, false)); }
public void FloatSerDe() { var avroSerializer = new AvroSerializer <float>(schemaRegistryClient); avroSerializer.Configure(new Dictionary <string, string>(), false); var avroDeserializer = new AvroDeserializer <float>(schemaRegistryClient); avroDeserializer.Configure(new Dictionary <string, string>(), false); byte[] bytes; bytes = avroSerializer.Serialize(testTopic, 123f); Assert.Equal(123f, avroDeserializer.Deserialize(testTopic, bytes, false)); }
public void ISpecificRecord() { var user = new User { favorite_color = "blue", favorite_number = 100, name = "awesome" }; var serializer = new AvroSerializer <User>(schemaRegistryClient); serializer.Configure(new Dictionary <string, object>(), false); var deserializer = new AvroDeserializer <User>(schemaRegistryClient); deserializer.Configure(new Dictionary <string, object>(), false); var bytes = serializer.Serialize("topic", user); var result = deserializer.Deserialize("topic", bytes); Assert.Equal(user.name, result.name); Assert.Equal(user.favorite_color, result.favorite_color); Assert.Equal(user.favorite_number, result.favorite_number); }