Пример #1
0
        public virtual void TestGenericAvroReaderByReaderSchema()
        {
            byte[] fooV2Bytes = fooV2Schema.Encode(fooV2);

            var genericAvroSchemaByReaderSchema = new GenericAvroReader(fooV2Schema.AvroSchema, fooV2Schema.AvroSchema, new byte[10]);
            var genericRecordByReaderSchema     = genericAvroSchemaByReaderSchema.Read(new MemoryStream(fooV2Bytes));

            Assert.Equal("foo1", genericRecordByReaderSchema.GetField("Field1"));
            Assert.Equal(10, genericRecordByReaderSchema.GetField("Field3"));
        }
Пример #2
0
        public virtual void TestGenericAvroReaderByWriterSchema()
        {
            byte[] fooBytes = fooSchema.Encode(foo);

            var genericAvroSchemaByWriterSchema = new GenericAvroReader(fooSchema.AvroSchema);
            var genericRecordByWriterSchema     = genericAvroSchemaByWriterSchema.Read(new MemoryStream(fooBytes));

            Assert.Equal("foo1", genericRecordByWriterSchema.GetField("Field1"));
            Assert.Equal("bar1", genericRecordByWriterSchema.GetField("Field2"));
            Assert.Equal("notNull", genericRecordByWriterSchema.GetField("FieldUnableNull"));
        }