Use Hypothesist to validate received messages as a MassTransit consumer.
var expected = new Message(1234); // <-- records are awesome!
var observer = Observer.For<Message>();
var bus = Bus.Factory
.CreateUsingRabbitMq(cfg =>
{
cfg.ReceiveEndpoint("...", e =>
{
e.Consumer(observer.AsConsumer);
});
});
await bus.StartAsync();
var endpoint = await bus.GetPublishSendEndpoint<Message>();
await endpoint.Send(message);
await hypothesis
.On(observer)
.Timebox(10.Seconds())
.Any()
.Match(expected)
.Validate();