Database Reference
In-Depth Information
Saga handler unit testing
We will start testing saga code from \BasicWCF2\MVCApp -
WCF\UnitTestHandlers\ , where we have various unit tests, including a copy of the
MySaga code in UnitTestSaga2.cs . Again, a sample of some of the workings can be
found at http://docs.particular.net/NServiceBus/unit-testing . Many of the same principles
apply as we saw in unit testing the message handler, except now it will be saga handler, and
our testing moves from Test.Handler to Test.Saga . Now, we can study the source
code from https://github.com/Particular/NServiceBus/blob/develop/src/NSer-
viceBus.Testing/Saga.cs .
One thing to note is that if a saga entity object is deleted in different function calls, with
MarkAsComplete() , these should be tested separately because once we delete the ob-
ject, we cannot delete them again. For example, in our tests:
In this snippet, we are testing the IHandleMessages<ResponseCommand> message
handler in the first test case, and in the second test case, we are testing
IHandleTimeouts<SendCommand> separately as they delete the saga object. We are
passing in prefabbed messages in the code to see whether they work well with the normal
messages.
The saga handler itself will act as an intermediate between the MVCApp and the WCF cli-
ent. This is needed so that it can timeout after three hours in case there is no response from
the WCF service.
Search WWH ::




Custom Search