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()).Retur开发者_JS百科ns(new[] {tax1, tax2});
this.service.LoadServiceTaxes();
this.sgtrMock.Verify(r => r.RetrieveCurrentTaxes(), Times.Once());
Any ideas about what can be happening?
There's a catch - Moq objects are not the intercepted objects, they're proxies.
精彩评论