Rework integration with Moq to support generic methods
See original GitHub issueThis issue is to track our activities regarding rework of Moq integration. Currently we are creating Mock<T>
using reflection and then configure each method individually using reflection. Due to this approach we have a limitation and do not support generic methods, as we cannot configure all possible instantiations upfront.
We should change our integration approach and instead register AutoFixture as default value provider. This way we inject “passively” and are invoked by Moq when value is required. We are already following that way with NSubstitute and it works pretty well.
We haven’t investigated yet whether it’s possible, but @stakx promised to give it a look one day.
Let’s postpone this activity till the moment we start our work on v5, as this change might require us to change minimum supported version for Moq. Unless somebody wants to look upfront to prepare Moq for this.
I’ll update this issue once we start work on v5.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13
Top GitHub Comments
This looks promising, except for the fact the mock is still tight to the interface. However, I expect most of reflection code could be replaced by this.
@zvirja: Thanks for the reminder!
Someone noticed a while ago over at Moq’s repo that due to the accessibility of
DefaultValueProvider
’s methods, these providers aren’t as composable as they could be. I’ve been wanting to fix this in one of the next minor releases. It’ll likely be a very small breaking change. I thought I’d mention it here so that we can coordinate versions / release schedules if needed.Also, if anyone here finds other problems with Moq’s
DefaultValueProvider
, please let me know.