Comments (2)
Version 2 works for me without RedundantArgumentMatcherException and is the right syntax.
Personally I would ask if it is really a good thing to use a mocking framework for this test?
Why not just write the test without it?
E.g.:
[TestMethod]
public void TestIt()
{
var it = new DoIt();
int? value1 = null;
int? value2 = null;
var actual = it.Execute((x, y) =>
{
value1 = x;
value2 = y;
return true;
});
actual.Should().BeTrue();
value1.Should().Be(1);
value2.Should().Be(2);
}
Not as fancy as the NSubstitute version but way easier to understand.
from nsubstitute.
Thank you, so the 2nd way is probably what I need to go for, maybe I need an update.
But yeah you make a good point, I can do all that funky mocking manually and at least I have control and know what it is doing.
Damn I fell back into the "mock all the things" trap.
Cheers
from nsubstitute.
Related Issues (20)
- Substitute not called, if argument variable is also out variable HOT 2
- Substiture for ILoggerFactory.CreateLogger<T> HOT 2
- NSubstitute/Castle proxy fail to create substitute that returns a derived class from abstract that satisfies interface implicitly HOT 5
- Return for specific args: Arrays HOT 2
- NSubstitute Received() throws System.NullReferenceException on Grpc mocked call HOT 3
- Generic setup fails with unexpected error message HOT 6
- RobiniaDocs API Explorer
- Unable to replace Moq IsAnyType() to Arg.AnyType HOT 1
- `Arg.Any<T>()` behaves strangely when it's stored in a variable instead of being passed directly
- Properties from a substitute object are empty when accessing in a Received.InOrder bloc
- Compatibility issue with XUnit's `IClassFixture` HOT 2
- Cannot mock an interface method that returns a generic collection with dynamic type HOT 2
- Assertion passes when an argument is used from the substitute itself HOT 1
- Missing/Old explanation in documentation for exception extensions
- Customize SubstituteFactory. HOT 3
- NSubstitute seems not to recognize the parameter order correctly (string default method parameter null) HOT 1
- Mocked Method returning null? HOT 1
- Compiler error when using Arg.Is<Arg.AnyType> HOT 4
- NSubstitute keeps reference to GC collectable objects while detached from events HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsubstitute.