1 year ago
#375069
Nivaldo Frigo
Problem mocking MassTransit method for testing
I'm writing a test for a Consumer using masstransit.
var _context = new Mock<ConsumeContext<AcionaMessageCommand>>();
_context.Setup(x => x.GetRedeliveryCount()).Returns(1);
when running it is returning error:
Unsupported expression: x => x.GetRedeliveryCount() Extension methods (here: RetryContextExtensions.GetRedeliveryCount) may not be used in setup / verification expressions
Could anyone tell me a way to mock this method, or another way to do this?
I tried to make a mock using:
_context.Setup(x => x.Headers.Get<int>("MT-Redelivery-Count")).Returns(1);
But in this case it always returns zero
c#
testing
mocking
masstransit
0 Answers
Your Answer