Exemplo n.º 1
0
        public void SchemaWrite(AvroSchema schema, string expectedCanonicalAvro, string expectedDefaultAvro, string expectedFullAvro)
        {
            var canonicalAvro = new StringBuilder();

            using (var writer = new StringWriter(canonicalAvro))
                AvroParser.WriteAvroCanonical(writer, schema);
            var actualCanonicalAvro = canonicalAvro.ToString();

            var defaultAvro = new StringBuilder();

            using (var writer = new StringWriter(defaultAvro))
                AvroParser.WriteAvro(writer, schema);
            var actualDefaultAvro = defaultAvro.ToString();

            var fullAvro = new StringBuilder();

            using (var writer = new StringWriter(fullAvro))
                AvroParser.WriteAvroFull(writer, schema);
            var actualFullAvro = fullAvro.ToString();

            Assert.AreEqual(expectedCanonicalAvro, actualCanonicalAvro, "Canonical form mismatch");
            Assert.AreEqual(expectedDefaultAvro, actualDefaultAvro, "Default form mismatch");
            Assert.AreEqual(expectedFullAvro, actualFullAvro, "Full form mismatch");

            actualCanonicalAvro = schema.ToAvroCanonical();
            actualDefaultAvro   = schema.ToAvro();
            actualFullAvro      = schema.ToAvroFull();

            Assert.AreEqual(expectedCanonicalAvro, actualCanonicalAvro, "Extension - Canonical form mismatch");
            Assert.AreEqual(expectedDefaultAvro, actualDefaultAvro, "Extension - Default form mismatch");
            Assert.AreEqual(expectedFullAvro, actualFullAvro, "Extension - Full form mismatch");
        }