mhinze / ShortBus

In-process mediator with low-friction API
MIT License
210 stars 41 forks source link

Mocking Mediators and Handlers #42

Open chadangerer opened 8 years ago

chadangerer commented 8 years ago

I am looking for a best practice on mocking a handler that returns a result.

For instance I have a service that I would like to get under test. This service has an IMediator injected via constructor injection. Throughout the service I make use of Mediator.Request(SomeDataQuery).Data to get data for processing. I have multiple Mediator requests using different requests.

I am looking for a recommended way to mock the mediator and then setup the results from the various Handle methods.

If it helps I am using Ninject as my IoC container in my main application.

Thanks.