-
Notifications
You must be signed in to change notification settings - Fork 618
Description
Is your feature request related to a problem? Please describe.
Currently the method is defined as following:
HandleBasicDeliver in IAsynBasicConsumer is defined as following
rabbitmq-dotnet-client/projects/RabbitMQ.Client/client/api/IAsyncBasicConsumer.cs
Lines 49 to 55 in e247e8b
| Task HandleBasicDeliver(string consumerTag, | |
| ulong deliveryTag, | |
| bool redelivered, | |
| string exchange, | |
| string routingKey, | |
| ReadOnlyBasicProperties properties, | |
| ReadOnlyMemory<byte> body); |
Passing in ReadOnlyBasicProperties directly and not the interface ReadOnlyBasicProperties makes it hard to test in Unit Tests via mocks, the type is sealed and has no easy constructors.
I have a rather large suit of mocked tests of my derived types of DefaultAsyncBasicConsumer et. al.
Describe the solution you'd like
It would be nice if the method is either using the interface or ReadOnlyBasicProperties gets a constructor in the other direction from BasicProperties, just like the other way round.
Describe alternatives you've considered
I'm currently using the wireformatting directly to create the type:
public static ReadOnlyBasicProperties FromBasicProperties(this BasicProperties basicProperties)
{
var writeable = (IAmqpWriteable)basicProperties;
var bufferLength = writeable.GetRequiredBufferSize();
var array = new byte[bufferLength];
var length = writeable.WriteTo(array);
var span = array.AsSpan(0, length);
var readOnlyBasicProperties = new ReadOnlyBasicProperties(span);
return readOnlyBasicProperties;
}This works but kinda feelds like a crutch.
Additional context
No response