You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice to be able to do new Mock<MockMe>(); without having to specify params.
Maybe have it choose simplest ctor (least num params) and then attempt to throw in mocks of these parameters (or default values).
Here new Mock<MockMe>(); would be equiv of new Mock<MockMe>(Mock.Of<ISomeDependency>());
The text was updated successfully, but these errors were encountered:
Moq is not a DI container and as far as I am aware, it doesn't strive to be one. If we added this functionality to Moq, it would either be very incomplete (when compared to a proper DI container), or we'd have to bring in a lot of functionality that has nothing to do with mocking. Both outcomes are equally undesirable.
It would be much better, IMO, to build this functionality / integration outside of the core library. Say, create a helper function that analyzes the desired type's parameters, fetches appropriate values from somewhere else, then invokes the Mock<T> ctor with these values.
If you don't want to build this yourself, I'm sure there are existing projects that do this kind of thing for you -- AutoFixture and Moq.AutoMock come to mind.
Has this been considered?
Would be nice to be able to do
new Mock<MockMe>();
without having to specify params.Maybe have it choose simplest ctor (least num params) and then attempt to throw in mocks of these parameters (or default values).
Here
new Mock<MockMe>();
would be equiv ofnew Mock<MockMe>(Mock.Of<ISomeDependency>());
The text was updated successfully, but these errors were encountered: