0

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

  • duplicate of https://stackoverflow.com/questions/562129/how-do-i-use-moq-to-mock-an-extension-method – Cobster Apr 04 '22 at 22:15
  • Consider reviewing the docs here https://masstransit-project.com/usage/testing.html – Nkosi Apr 04 '22 at 22:24

0 Answers0