In the test project I wanted to execute the codes in the CallbackReceivedEventHandler
So I tried to "Publish" something to this consumer but in the end the consumer is not invoked. What did I do wrong?
I had to make the consumer response something then use the RequestClient in the test project... it is not a good workaround... the consumer should not response anything
please help
Application Project
public class CallbackReceivedEventHandler : IConsumer<CallbackReceivedEvent>
{
public async Task Consume(ConsumeContext<CallbackReceivedEvent> context)
{
//Breakpoint is here
...
await context.RespondAsync(new CallbackReceivedEventResponse()); // I want to remove this thing
}
Test Project
provider = new ServiceCollection()
.AddMassTransitInMemoryTestHarness(cfg =>
{
configurator.AddConsumers(typeof(CallbackReceivedEventHandler));
})
.AddGenericRequestClient()
.BuildServiceProvider(true);
var harness = provider.GetRequiredService<InMemoryTestHarness>();
await harness.Start();
var bus = provider.GetRequiredService<IBus>();
CallbackReceivedEvent input = new()
// NOT WORK
await bus.Publish(input); //KO! the consumer is not called (breakpoint in Consume is not hit)
// WORK!
var requester = bus.CreateRequestClient<CallbackReceivedEvent>();
await requester.GetResponse<CallbackReceivedEventResponse>(input); //OK! the consumer is called (breakpoint in Consume is hit)