Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.You’ve run into it. MediatR throwing an
InvalidOperationException when you didn’t have a matching handler for a request. There’s a fairly simple solution to prevent this: Find MediatR Requests without Handlers.
So here’s some quick code you can throw in a unit test to verify you don’t have any missing handlers.
Find MediatR Requests without HandlersThe above code uses reflection to get all the
RequestHandler<,>. Also worth mentioning it leverages Autofac for the
IsClosedTypeOf method in the linq query.