question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to pass a delegate to Wrapping()

See original GitHub issue

In certain test scenarios on our side we want to set up fake calls for a wrapping fake before the actual application started and the actual object to be wrapped becomes available.

It would be great to have an overload for Wrapping() that takes a delegate to allow the following:

1. Set up fake object wrapping a delegate that returns a field which is currently null
2. Start the subject-under-test application
3. Obtain the object-to-be-wrapped from the application and save it to the field
4. Any calls to the fake which are not set up are now passed on to the delegate -> to the field

Best regards, D.R.

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
blairconradcommented, Aug 15, 2023

Congratulations, @drauch! Happy fathering!

On to business. Because I still don’t understand, it sounds to me like at the time you decide to swap in the Fake, you already have access to the original service that you’d be wrapping. I’m sure I’m still missing something, because if it were that easy, you wouldn’t be here. Still, we at FakeItEasy Canada don’t understand the situation in which this feature would apply, nor how far-reaching the benefit would be.

I propose that until you (or maybe one of your teammates, since it sounds like this is a work project) can show up with an example, or very detailed explanation of the flow (which we can ask annoying questions about), we close the issue. And then it can be reopened when there’s more information.

1reaction
drauchcommented, Apr 27, 2023

That’s correct, yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How can I use delegates to pass methods in a thread ...
new Thread() takes a ThreadStart (or ParameterisedThreadStart) argument, and your DoDelegatedMethod callback doesn't have the right ...
Read more >
Using Delegates - C# Programming Guide
An instantiated delegate can be invoked as if it were the wrapped method ... This allows a method to accept a delegate as...
Read more >
Wrapping delegates with Swift async/await and continuations
In this article you will learn how to convert or use existing delegate patterns and wrap them with Swift's structured concurrency to use...
Read more >
Passing delegated properties to functions (instead of ...
I just pass Boolean that wrapped in object (somenting like AtomicBoolean) as last parameter. abstract class Observable { fun subscribe() ...
Read more >
What is the purpose of a wrapper class that does nothing ...
This pattern is called "Delegation". Here is a simple example of an implementation that adds a System.out when setLocale is called:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found