I’m using Dependency Injection in my MassTransit consumers. To test these consumers you can use MassTransit in-memory test harness;
But when you try to use the code above with a consumer that has dependencies injected through the constructor, it will not work and you end up with the following error message:
'SubmitOrderConsumer' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method 'ConsumerTestHarnessExtensions.Consumer<T>(BusTestHarness, string)'
To fix this, you have to change your test code and use the consumer factory method: