Comments (6)
@svisser, @thomaslevesque pointed out in sidechat (but didn't want to publicly shame me) that I erred earlier.
This is similar to defining any constraint on a faked method without specifying an action, which it what "registers" the configuration. It's a common mistake and is diagnostic FakeItEasy0001 in the FakeItEasy Analyzers.
In fact, FakeItEasy0001 would not be triggered. It detects an A.CallTo(…)
with no followup call at all. The Analyzer would see .MustNotHaveHappened()
and therefore not complain.
The correct statement is that .MustNotHaveHappened()
doesn't perform any actual configuration on the fake, so the capturing argument is never hooked up to any call handlers.
from fakeiteasy.
Hi, thanks both for clarifying how this works. I'm fairly new to using this library and this helps with understanding how to use it as intended.
Thanks also for the documentation change, that should be helpful as well. I'm happy for the issue to be closed.
from fakeiteasy.
The docs have been updated.
from fakeiteasy.
Hi @svisser,
You need to configure the call for the capture to work. You're only asserting it.
If I add this:
A.CallTo(() => obj.GenerateValue(capturedInput._)).Returns("hello");
It works as expected.
TBH, I don't even know what it would means to use capturedInput._
in an assertion. We might need to update the docs to clarify this.
from fakeiteasy.
This is similar to defining any constraint on a faked method without specifying an action, which it what "registers" the configuration. It's a common mistake and is diagnostic FakeItEasy0001 in the FakeItEasy Analyzers.
TBH, I don't even know what it would means to use
capturedInput._
in an assertion.
I see it as a semi-convenient way to provide some constraint. Avoids having to write A<TestObject>._
. That being said, I wouldn't expect there to be much need for it. I may be wrong, but I'd think most time when you're using a capturing argument at all, you'd examine the captured values instead of verifying that certain calls were made.
Still, there's no harm in updating the documentation as you suggest, @thomaslevesque.
from fakeiteasy.
Glad it helped, @svisser. Sorry for your pain. Do consider using the Analyzer to help catch bugs that we couldn't make impossible to code up.
from fakeiteasy.
Related Issues (20)
- Match enumerable arguments by comparing contents rather than via `Equals` HOT 8
- Add assertion similar to Moq's `VerifyNoOtherCalls` HOT 8
- Feature request: ReturnsNextFromSequenceLazily() HOT 6
- Feature request: Then().Returns...() HOT 5
- Issue using Result Pattern and trying to fake a response
- Release 8.0.1 HOT 1
- Interface type property not return created object HOT 3
- How to fake a type that have `dynamic` (ExpandoObject) properties? HOT 3
- DoesNothing() and implicit creation options throws ArgumentException HOT 5
- Release 8.1.0 HOT 1
- Include README in NuGet package HOT 1
- Silence security vulnerability complaints over Microsoft.NETCore.App 2.1.0 HOT 2
- Release 8.2.0 HOT 1
- Fake does not work as argument constraint HOT 4
- Test fails on Version 8 but succeeds on Version 7 HOT 4
- Expose caught exception(s) in protected/abstract constructors HOT 10
- Invoke method after calling an Entities public method/behaviour HOT 7
- Release vNext
- Document how to use InternalsVisibleTo from project files HOT 2
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 fakeiteasy.