public static IKafkaWriter Write(this IKafkaWriter writer, IMemberAssignment assignment, IProtocolTypeEncoder encoder) { encoder.EncodeAssignment(writer, assignment); return(writer); }
public static void AssertCanEncodeDecodeResponse <T>(this T response, short version, IProtocolTypeEncoder encoder = null) where T : class, IResponse { var encoders = ImmutableDictionary <string, IProtocolTypeEncoder> .Empty; if (encoder != null) { encoders = encoders.Add(encoder.Type, encoder); } var context = new RequestContext(16, version, "Test-Response", encoders, encoder?.Type); var data = KafkaDecoder.EncodeResponseBytes(context, response); var decoded = KafkaEncoder.Decode <T>(context, data, true); if (!response.Equals(decoded)) { var original = response.ToFormattedString(); var final = decoded.ToFormattedString(); Console.WriteLine($"Original\n{original}\nFinal\n{final}"); Assert.That(final, Is.EqualTo(original)); Assert.Fail("Not equal, although strings suggest they are?"); } }
public static IKafkaWriter Write(this IKafkaWriter writer, IMemberMetadata metadata, IProtocolTypeEncoder encoder) { encoder.EncodeMetadata(writer, metadata); return(writer); }