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
Can concrete (and sealed) classes be made mockable (without virtual methods)? Because this would save a lot of frustrations with duplicate code, caused by useless interfaces.
The text was updated successfully, but these errors were encountered:
Concrete classes: perhaps. But otherwise, the answer is a definite no. Moq cannot create mocks for non-inheritable (e.g. sealed or static) types. And it cannot setup non-overridable (e.g. sealed, static or non-virtual) methods. As a general rule, if you could not do something manually, then Moq likely cannot do it either.
In fact, there are few mocking libraries that can do what you're asking for. TypeMock or JustMock are perhaps the best-known, I am not sure if there are any others. (Microsoft Fakes, perhaps?)
Can concrete (and sealed) classes be made mockable (without virtual methods)? Because this would save a lot of frustrations with duplicate code, caused by useless interfaces.
The text was updated successfully, but these errors were encountered: