[DOC] Add NSubstituteDefaultFactory
config steps to documentation
#837
Labels
NSubstituteDefaultFactory
config steps to documentation
#837
Would be great to get the info from #705 into the official docs:
Actually the API you are changing is designed exactly with open/closed principle in mind 😊 It's open for extensibility, but is closed for modification and is in fact implementing the immutability pattern. To modify the container you can create a copy and then customize it as needed. I've even added the
.Decorate()
method which allows you to decorate the existing implementation by enhancing it - yet another example of the open/closed principle 😉I do admin though that the flow is not really well-documented, so it might be a bit non-trivial to discover it.
The original design was to follow the following steps:
NSubstituteDefaultFactory.DefaultContainer.Customize();
SubstitutionContext.Current
as early as possible. Usage of Module Initializers is ideal here.Here is example of the code to follow. From what you mentioned above, it seems it should perfectly cover the flow 😊
I wouldn't say we had a deep though behind that, it just wasn't implemented.
In my day-to-day life I'm using NSubstitute in a combination with the AutoFixture library which provides way richer auto-generation capabilities that pure NSubstitute. And that one is handling the
ValueTask
type. I would say it perfectly complements NSubstitute, but of course requires a bit of learning 🤓Let me know the snippet above is helping you to solve the needs.
As for the PR, I suggest to not merge it to stick to the current design.
Originally posted by @zvirja in #705 (comment)
The text was updated successfully, but these errors were encountered: