views:

41

answers:

0

Hello!

We are trying to use PostSharp, more specifically the OnMethodInvocationAspect, to intercept the methods of a class.

The code runs fine, but when testing it with MOQ, it seems to be messing up with my mocks.

If I remove the aspects, all tests succeed. But, if I turn the aspects back on, the expectations on the MOQ mocks are not met.

Here is a snippet taken from one of our unit tests:

this.sgtrMock.Setup(r => r.RetrieveCurrentTaxes()).Returns(new[] {tax1, tax2});
this.service.LoadServiceTaxes();
this.sgtrMock.Verify(r => r.RetrieveCurrentTaxes(), Times.Once());

Any ideas about what can be happening?