Dear .NET friends, how do you like to create your mocks? 🤔 …
With a framework like Moq or manually?
I don’t actually do a huge amount of mocking, but when I do I prefer to just manually create an instance of some interface and set appropriate return values.
I never really liked the Moq syntax (I know there’s others) and I’d rather have one less dependency for the team to learn and maintain but I’m super curious about what your thoughts are?
ChatGPT helped me create the example below ⬇ of using Moq (on top) and a typical hand rolled equivalent on the bottom.
Click on the image for a larger view in a new window.
I originally posted this on my LinkedIn a couple of days before #moqgate.
The whole thing is a shame as Moq has been used by many devs for over 12 years without issue but it does really bring home my point about having one less dependency to manage. When we rely on these packages we are basically at the mercy of their creators.