public void ProtocolWrite(AvroProtocol protocol, string expectedCanonicalAvro, string expectedDefaultAvro, string expectedFullAvro)
        {
            var canonicalAvro = new StringBuilder();

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

            var defaultAvro = new StringBuilder();

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

            var fullAvro = new StringBuilder();

            using (var writer = new StringWriter(fullAvro))
                AvroParser.WriteAvroFull(writer, protocol);
            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 = protocol.ToAvroCanonical();
            actualDefaultAvro   = protocol.ToAvro();
            actualFullAvro      = protocol.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");
        }
Пример #2
0
        public void UnknownSchemaTest()
        {
            var schema = new UnknownSchema();

            var canonicalAvro = new StringBuilder();

            using (var writer = new StringWriter(canonicalAvro))
                Assert.Throws(typeof(AvroException), () => AvroParser.WriteAvroCanonical(writer, schema));
        }