NServiceBus Testing Upgrade Version 6 to 7

Component: Testing
This page targets a pre-release version and is subject to change prior to the final release.

Upgrade to NServiceBus Version 7

NServiceBus.Testing requires NServiceBus Version 7.

As part of upgrading to NServiceBus.Testing Version 7, projects will also require an upgrade to NServiceBus Version 7.

AssertSagaCompletionIs

The AssertSagaCompletionIs method has been obsoleted and replaced by ExpectSagaCompleted and ExpectSagaNotCompleted.

7-pre NServiceBus.Testing
Test.Saga<MySaga>()
    .ExpectSagaCompleted()
    .WhenHandling<CompleteSagaMessage>();
6.x NServiceBus.Testing
Test.Saga<MySaga>()
    .WhenHandling<CompleteSagaMessage>()
    .AssertSagaCompletionIs(true);

Note how the ExpectSagaCompleted and ExpectSagaNotCompleted expectations must be placed before a When method, similar to other expectation methods.

ExpectHandleCurrentMessageLater

The ExpectHandleCurrentMessageLater has been obsoleted as IMessageHandlerContext.HandleCurrentMessageLater() has been deprecated in NServiceBus Version 7.

WhenHandling

An overload of the WhenHandling method has been added which accepts a preconstructed message.

7-pre NServiceBus.Testing
var message = new CompleteSagaMessage();

Test.Saga<MySaga>()
    .ExpectSagaCompleted()
    .WhenHandling(message);
6.x NServiceBus.Testing
var message = new CompleteSagaMessage();

Test.Saga<MySaga>()
    .WhenHandling<CompleteSagaMessage>(msg => { /* msg has already been created */ })
    .AssertSagaCompletionIs(true);

Related Articles


Last modified