Open BenjaminAbt opened 8 months ago
I like the idea here, but IMO this GitHub issue is very broad and therefore hard to fix.
people no longer had to google workarounds.
I don't know what this exactly means, other than the given examples
Hi @BenjaminAbt ,
Sorry for the delayed response. If you have the time would you be happy to send your branch as a PR?
A few notes on the existing commit:
ReceiveAtLeast
. We already dump so much into intellisense with extension methods on Object and I'd prefer not to exacerbate the problem. 😅 Quantity.Matches
with a List
, so Count()
would probably end up being more efficient than something like .Take(minInclusive).Count()
for this case. Any thoughts on whether we should change Matches
to take a list to make this more obvious?AtMost
, LessThan
, MoreThan
as well?Quantity
that are currently missing doc comments? As per @304NotModified's reply, if you have other specific examples please create an issue/s for them. 👍
I like the idea here, but IMO this GitHub issue is very broad and therefore hard to fix.
Yes, that was the intention. I wanted to find out what the general attitude was before I put more time into it; also because there have been statements about it in the past (see above).
If you have the time would you be happy to send your branch as a PR?
For sure.
I'd prefer to avoid ReceiveAtLeast. We already dump so much into intellisense with extension methods on Object and I'd prefer not to exacerbate the problem.
Yes, I understand this, but I see devs struggling. IntelliSense is just normal in our .NET / Visual Studio ecosystem, and I just see developers browsing IntellISense instead of people looking at the docs. It's not a one-off thing either, I see it consistently.
Did you want to add any of AtMost, LessThan, MoreThan as well?
Sounds good.
Existing problem, but if you do send through a PR would you also be able to add code docs to the public members of Quantity that are currently missing doc comments?
Yes.
I don't know what this exactly means, other than the given examples
There is one thing I do differently now and recommend to other people: use CHatGPT instead of GitHub Copilot to migrate from Moq to NSubstite.
The results are better and people need less help with things they can't find the equivalent for. GitHub Copilot has sometimes suggested things for NSubstite that correspond to Moq's API - of course that doesn't work because they dont exist.
Is your feature request related to a problem? Please describe.
NSubstitute is a great library and is one the preferred test tool for mocks, not least because of the Moq Drama. However, some situations require code that are not intuitive and are comparatively inconvenient to implement. On the one hand, you can read this in many blogs that present migration docs from Moq to NSubstitute, but I also get this as feedback myself when I show different test libraries in training courses. So it is a real disadvantage in the everyday life of NSubstitute. I'm noticing it myself, as the number of requests for NSubstitute coaching / support is currently rising.
For example, converting
Times.AtLeast()
from Moq to NSubstitute is very inconvenient and not sustainable. There is the topic Received range of calls #558, in which there is a workaround withWithin
.In addition, the statement
Personal impressions are perfectly okay, and it would also be okay if several methods ultimately provide the same or similar tests. The easier tests can be written, the better our .NET ecosystem will be.
Describe the solution you'd like
It would be great if many things were easier to implement with NSubstitute and people no longer had to google workarounds. That would make it easier to accept and move from Moq to NSubstitute. A small example for fixing AtLeast - a specific case for my customers who are annoyed by this - can be implemented with just a few lines of code. https://github.com/nsubstitute/NSubstitute/compare/main...BenjaminAbt:NSubstitute:feature/more-methods
Like my customers, we are currently helping ourselves with extensions such as
but it would be better if there were sustainable, convenient and intuitive things directly in NSubstitute.
Thanks ♥