Skip to content

Latest commit

 

History

History

Rebus

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

nuget

Hypothesist.Rebus

Use Hypothesist to validate received messages as a Rebus handler.

Arrange

var expected = new Message(1234);
var observer = new Observer<Message>();
using var activator = new BuiltinHandlerActivator()
    .Register(observer.AsHandler); // <-- here's the magic

var bus = Configure.With(activator)
    .Transport(t => t.UseRabbitMq("...")
    .Start();

await bus.Subscribe<Message>();

Act

await bus.Publish(new Message(1234)); // <-- from the system under test

Assert

await Hypothesis
    .On(observer)
    .Timebox(2.Seconds())
    .Any()
    .Match(expected)
    .Validate();

Slightly more convenient then the inline handler method: activator.Handle<Message>(m => observer.Observe(m)).