Code Monkey home page Code Monkey logo

Comments (6)

blairconrad avatar blairconrad commented on June 10, 2024 2

@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.

svisser avatar svisser commented on June 10, 2024 1

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.

thomaslevesque avatar thomaslevesque commented on June 10, 2024 1

The docs have been updated.

from fakeiteasy.

thomaslevesque avatar thomaslevesque commented on June 10, 2024

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.

blairconrad avatar blairconrad commented on June 10, 2024

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.

blairconrad avatar blairconrad commented on June 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.