public static async Task <TMessage> GetDeserializedMessageAsync <TMessage>(this Stream stream, CancellationToken cancellationToken) where TMessage : class { var message = await stream.ReadMessageAsync(cancellationToken).ConfigureAwait(false); return(BinaryMessageSerializer.Deserialize <TMessage>(message)); }
public void The_binary_formatter_should_make_mouths_happy() { byte[] serializedMessageData; IMessageSerializer serializer = new BinaryMessageSerializer(); using (MemoryStream output = new MemoryStream()) { serializer.Serialize(output, _message); serializedMessageData = output.ToArray(); } using (MemoryStream input = new MemoryStream(serializedMessageData)) { SerializationTestMessage receivedMessage = serializer.Deserialize(input) as SerializationTestMessage; Assert.AreEqual(_message, receivedMessage); } }