2
votes

I have been working on unit testing a Mass Transit Project using InMemoryTestHarness.

I have referred to the following github code to work with it

ConsumerTest_Specs.cs

Could someone please explain what the following properties

  • Sent
  • Published
  • Consumed

to the InMemoryTestHarness _harness object actually mean.

Although the code has a Test Method associated with each, I'ld like a bit more explanation to it.

Thanks.

1
These are collections of all messages that were sent, published and consumed by the harness. - Alexey Zimarev

1 Answers

1
votes

I Know the comment have the concise answer but, I think I can make it more clear by adding some adition info.

The InMemoryTestHarness takes the place of your mMessageBroker for the unit test instance, just like a Smart Mock. So, as a broker it has all published messages, but also keeps tracking of all messages that were transmitted.

  • Sent: Direct commands/Messages, just like some RPC, but using the message broker as a channel. All messages that used the Send() method while the harness is active have a copy here.
  • Published: Event-like Messages, following a PubSub pattern. All messages that used the Published() method while the harness was active have a copy here.
  • Consumed: All messages that were consumed while the harness was active. here we have an important consideration:

    Only consumers that were register in the harness will consume messages, so you have control of which consumers are active