Updating tests from 3.4.1 to 3.5.7 issues

17 views
Skip to first unread message

loki...@gmail.com

unread,
Aug 7, 2017, 4:24:21 AM8/7/17
to masstransit-discuss
Hey,

I've been trying to upgrade the tests in our project after we updated the package, seems there have been some considerable changes since 3.4.1!

The issue I'm having is with the InMemoryTestFixture, assuming the set up is the same as usual, except a few method name changes, the issue is coming from the Handled<T>(IReceiveEndpointConfigurator) method. Previously, in 3.4.1 it appears to have waited for the consumer to finish processing the message before the Task ran to completion, now however it seems like Handled returns immediately after the message is received and the task is already processed. Simple stripped down example below:

public class BehaviourTestHandler : InMemoryTestFixture
{
private Task<ConsumeContext<ITestCommand>> _received;

protected override void ConfigureInMemoryReceiveEndpoint(IInMemoryReceiveEndpointConfigurator configurator)
{
configurator.Consumer(() =>
new CommandHandlerLogger(
new CommandHandler(),
)
);

_received = Handled<ITestCommand>(configurator);
}

public async Task WhenACommandIsReceived()
{
await InputQueueSendEndpoint.Send<ITestCommand>(new { Parameter = "" });

await _received;
}

public void ThenItShouldDoWork()
{
// Checking called methods and full logic flow
}
public void Execute()
{
TestStack.BDDfy.BDDfyExtensions.BDDfy(this, "Test");
}
}

I must assume I'm doing something wrong, is there another function that waits for the command to be processed before it returns a completed task? Using the git repo tests as examples hasn't been productive, as most of those are single line processing of commands, it always appears to work, I shouldn't need to change the command handler itself to make the test pass either.

Is my only option to forgo the InMemoryTestFixture and just mock the ConsumeContext<T> and call my handler directly? Feels like a cheat when it worked fine in 3.4.1..
Reply all
Reply to author
Forward
0 new messages