-
-
Notifications
You must be signed in to change notification settings - Fork 820
Description
In our existing code base, we have lots of mocks, some being created specifically with MockBehavior.Strict
as their constructor parameter, but most with the parameterless constructor which implies calling with MockBehavior.Default
.
While the current situation is fine, we would like to experiment setting all mocks to Strict
mode and were looking for a way to globally say Default
is Strict
in our project(s) instead of the current Default
is Loose
.
This is not possible at the moment, mostly because MockBehavior
defines Default = Loose
If this was changed so that Default
has its own distinct value, the constructor could then do something like this:
this.behavior = (behavior == MockBehavior.Default) ? GlobalDefaultMockBehavior : behavior;
Where GlobalDefaultMockBehavior
has MockBehavior.Loose
by default but can be changed by a method yet to be written. Setting it via a flag in the assembly definition would be nice.
Obviously, any new value set into GlobalDefaultMockBehavior
has no impact on existing Mock<T>
instances, and thread safety of such a global value is nonexistent and should be documented as such.
I have seen Issue #1230 but I believe the request here is not for the same use case.