Unit Testing Consumers

561 views
Skip to first unread message

Charles M

unread,
Jan 19, 2015, 6:10:51 AM1/19/15
to masstrans...@googlegroups.com
Hi,

I am trying to unit test my consumers.

I have created mocks of all my dependencies. The problem arises when I try to call this method..

public void Consume(IConsumeContext<LogEvent> msg)
{
}

I need to somehow create an instance of msg to pass into this method. At the moment I have this as a starting point...

// Arrange
var msg = new MassTransit.Context.ConsumeContext<LogEvent>(
    << What to put here >>,
    LogEvent()
    {
        Message1 = "Test Message"
    });

// Act
consumer.Consume(msg);

What I can't work out how to do is to create something that implements MassTransit.IReceiveContext to create my test message.

Is this possible to do ?

Thanks.

Travis Smith

unread,
Jan 19, 2015, 7:04:56 AM1/19/15
to masstrans...@googlegroups.com
Out unit tests setup a bus with a loopback transport. It happens all in memory and you can test for just about anything in the pipeline. 
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/36ea0a84-5e00-4416-b921-bafe7d7841cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-Travis
Reply all
Reply to author
Forward
0 new messages