There is no simple built-in function that allows you to do something like this, but it should not be so difficult to do.
Essentially, you will need to modify the MockConstructorQuery so that it MockConstructorQuery constructor that takes the value MockBehavior and passes MockBehavior.Strict .
Now you cannot change this behavior in MockConstructorQuery , but this class contains only 9-10 lines of code, so you must create a new class that implements IMethodQuery using MockConstructorQuery as a starting point.
Similarly, you will also need to create custom ICustomization , which will be almost the same as AutoMoqCustomization , with the only exception that uses custom IMethodQuery with strict mock configuration instead of MockConstructorQuery . These are 7 more lines of code that you will need to write.
All that said, in my experience, using strict mocks is a bad idea . This will make your tests fragile and you will spend a lot of time fixing broken tests. I can only recommend that you do not, but now I have warned you; this is your foot.
source share