nsubstitute / NSubstitute

A friendly substitute for .NET mocking libraries.
https://nsubstitute.github.io
Other
2.67k stars 263 forks source link

Docs: fix overridable member documentation #599

Open dtchepak opened 4 years ago

dtchepak commented 4 years ago

From https://github.com/nsubstitute/NSubstitute/issues/222#issuecomment-557198534, saying protected virtual is substitutable is misleading. While technically possible (hacky) with the current API, it's not something we encourage and people should not expect to mock these members with NSubstitute.

By overridable we mean public virtual, protected virtual, protected internal virtual, or internal virtual with InternalsVisibleTo attribute applied.

dtchepak commented 4 years ago

Implementing this and realised it is actually a bit more nuanced. The documentation is referring to real code executing for non-overridable members. This includes code in protected virtual, even if these calls are not (easily) configurable via the NSubstitute API.

Will update the docs to try to reflect this a bit better.