Replies: 5 comments
This comment was marked as off-topic.
This comment was marked as off-topic.
-
(Sorry, I totally misinterpreted this issue's original post as I was under the false assumption that this was posted at the moq4 repo. Please ignore my above post.) |
Beta Was this translation helpful? Give feedback.
-
Actually any input is welcomed. I think I will try maybe also to put I have tried by myself to build Moq v5, but without success, I guess need to install newer C# compiler tools, maybe also re-configure Moq v5. I have checked also that Moq v5 nuget packages are not yet published - even not alpha / beta. Would be interested to try out Moq v5 as well. (What is still not working in v5 ?) |
Beta Was this translation helpful? Give feedback.
-
It looks like for Moq v4 this code indeed works:
Usage is quite trivial, something like this:
Need to try out on bit wider scope. |
Beta Was this translation helpful? Give feedback.
-
Unrelated to ticket - here are some benchmarks of proxy creation versus calling: https://github.com/mtamme/NProxy/blob/master/Documentation/BENCHMARKS.md Maybe need to try out NProxy later on. |
Beta Was this translation helpful? Give feedback.
-
By default when you create new Mock object - it allows to record methods being called, by placing them into "Invocations" property.
I would prefer to operate in real time and perform logging of methods being called and their call arguments.
By brief check of Moq v4 - I've noticed that this is far not simple thing to be done, as Moq does use
Castle.DynamicProxy.ProxyGenerator
, but it does not allow end-user of Moq to override call with it's own interceptor.What I've came up - is maybe I could just double proxy executing - so Moq would create one proxy and I would put second proxy on top of that one.
This did work correctly, however - then I wanted to switch from
Mock<interface>
toMock<abstract class>
- and then noticed that Mock does support such method asAs<TInterface>()
, which in a turn woul create a new copy of Mock with different generic parameter.To support all use cases as Mock does - it would require also mimic also
class AsInterface<TInterface> : LoggedMock<TInterface>
class, which drags more complexity into whole story.
Moverover - then I've noticed that Moq v5 was not based anymore on Castle core, with it's own mechanisms for logging interception.
Also if interception is done via logging - it's possible also to override existing Mock behavior and not to update Invocations at all (as it would eat more performance).
Just to illustrate what kind of logging I want to achive - this is something coded with Castle.Core / Moq v4.
Would it be possible to add into Moq v5 logging support or just to provide some code on how this could be done.
Beta Was this translation helpful? Give feedback.
All reactions