Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 01 2016 16:24
    jeremymeng synchronize #617
  • Apr 01 2016 14:28
    blairconrad commented #490
  • Apr 01 2016 11:07
    blairconrad commented #629
  • Mar 31 2016 14:14
    PascalK starred FakeItEasy/FakeItEasy
  • Mar 31 2016 13:00
    blairconrad commented #490
  • Mar 31 2016 12:48
    drauch commented #490
  • Mar 31 2016 10:57
    blairconrad commented #617
  • Mar 31 2016 10:52
    adamralph commented #617
  • Mar 31 2016 10:42
    blairconrad commented #617
  • Mar 31 2016 10:41
    blairconrad commented #617
  • Mar 31 2016 10:29
    adamralph commented #617
  • Mar 31 2016 09:27
    adamralph commented #637
  • Mar 31 2016 08:29
    cecilphillip commented #637
  • Mar 31 2016 06:27
    M-Zuber commented #637
  • Mar 31 2016 06:25
    thecodejunkie commented #637
  • Mar 31 2016 06:25
    adamralph commented #637
  • Mar 31 2016 06:24
    adamralph commented #637
  • Mar 31 2016 06:13
    adamralph labeled #637
  • Mar 31 2016 06:13
    adamralph labeled #637
  • Mar 31 2016 06:13
    adamralph assigned #637
Blair Conrad
@blairconrad
But the two properties are effectively two unrelated methods. You will have to set their values or configure their values separately.
Oh! One thing that does occur to me. After creating the Fake you might be able to configure one property to always return the value assigned to the other. e.g. (and I am not checking to see if this even compiles, but would later when I have time):
var fake = A.Fake<IInterface>(options => options.Implements<IInteface2>);
A.CallTo(() => ((IInterface2)fake).Property)).ReturnsLazily(call => ((IInterface)call.FakedObject).Property));
SecurIOTy
@SecurIOTy
Hmm I'll look into what you sent. I don't want to keep you. Thanks!
Blair Conrad
@blairconrad
But then assigning a value to IInterface2.Property later would undo that configuration (unless you configured the setter to write through to IInterface.Property similarly).
Oh, you won't keep me; I'll walk away regardless, but I'm happy to return to the question later.
If what I said doesn't apply, or just makes things worse, and you can share some sample misbehaving test code with a brief explanation, it's probably the best path to getting an answer.
SecurIOTy
@SecurIOTy
It WORKED
You're amazing @blairconrad
Blair Conrad
@blairconrad
Oh, wow. I did not see a notification for this, @SecurIOTy. I'm glad it worked. Happy FakeItEasying!
Blair Conrad
@blairconrad
Thomas Levesque
@thomaslevesque
Blair Conrad
@blairconrad
:tada:
Daniel Weinand
@devployment

Hello. I'm trying to create a fake of IOptionsMonitor<T>like this

var options = A.Fake<IOptionsMonitor<AllowedAppOptions>>();

A.CallTo(() => options.CurrentValue).Returns(new AllowedAppOptions());

As the faked object gets used by accessing CurrentValue I can see the following in the debugger

Method MetadataMethod(6000045 Microsoft.Extensions.Options.IOptionsMonitor`1::get_CurrentValue,0p) could not be resolved on type MetadataClassType(Castle.Proxies.ObjectProxy_3)

Am I missing something here or is it a general issue?

Thomas Levesque
@thomaslevesque
Hi @devployment
I haven't seen this before. Which version of FakeItEasy are you using? What's the target framework of your unit tests project?
Daniel Weinand
@devployment
Target framework is netcoreapp3.0. FakeItEasy is 5.4.0
Thomas Levesque
@thomaslevesque
Thanks. I'll see if I can reproduce it
Daniel Weinand
@devployment
If needed I can try to provide a minimal example later today.
Thomas Levesque
@thomaslevesque
When you say "I can see the following in the debugger", do you mean that the code executes correctly but prints this to the debug output?
Also, which version of Microsoft.Extensions.Options are you using? 3.0.0?
Thomas Levesque
@thomaslevesque
@devployment I'm unable to repro....
    class Program
    {
        static void Main(string[] args)
        {
            var monitor = A.Fake<IOptionsMonitor<MyOptions>>();
            A.CallTo(() => monitor.CurrentValue).Returns(new MyOptions());
            var options = monitor.CurrentValue;
        }
    }

    public class MyOptions
    {
        public string Foo { get; set; }
        public int Bar { get; set; }
    }
This code works fine, and there's nothing in the debugger output
Daniel Weinand
@devployment
@thomaslevesque, I can imagine that you're not able to reproduce. The message I see during debugging is not an issue. The issue was my code as I did not initialize the settings themselves. :anguished: So I expected an empty array but instead it returned null. Not related to FakeItEasy. All my fault. Sorry for making noise here.
Thomas Levesque
@thomaslevesque
No problem, glad you were able to resolve this!
Luke Marlin
@LukeMarlin
Hi there
I've got some time today so I wanted to finally take a look at FakeItEasy/FakeItEasy#1602
Blair Conrad
@blairconrad
:wave:
Nice!
It's a super long day here in most of Canada (25 whole hours!).
Luke Marlin
@LukeMarlin
Well @blairconrad you're quick to answer. Impressed :D
Blair Conrad
@blairconrad
If you've not updated lately, get the latest master. @thomaslevesque made things build on at least one flavour of Linux
Luke Marlin
@LukeMarlin
Yes, I noticed, thanks @thomaslevesque for all the work :)
Blair Conrad
@blairconrad
It's luck. I was sitting here trying to arrange a get-together with a cousin.
Luke Marlin
@LukeMarlin
I've been checking on my windows today because I didn't want to take time to make it all work on my arch though :)
Ah alright, glad to hear you're not sitting there all day long :)
Blair Conrad
@blairconrad
Oh. Your distro doesn't work out of the box...
Luke Marlin
@LukeMarlin
Maybe yes, maybe not, I'll give it a try later on.
Blair Conrad
@blairconrad
No. In fact, I'm going to start prepping beets to cook, so will be running back and forth to keyboard
Luke Marlin
@LukeMarlin
And since I'm using OSS vscode I have no debugger so that was no possible to try your lib blindly!
Alright, I've got a couple questions that I'll leave here for you to check whenever you can
Looking at the code so far, my first idea would be to maintain a register of matched calls with the rule that matched. You already have a list of matched calls so it could be doable to add the rule in that. However, that doesn't make it possible to fulfill all the cases you wanted to have (i.e: getting calls that matches a given rule while the object wasn't even configured)
I tried a bit anyway, but god you have a lot of interfaces ._.
I tried to sneak into "ApplyBestRule", but the interfaces you've listed on the issue are different than what we receive/access in there
I'd like to know if changing that method to also store the rule itself somehow would be an OK way to provide this feature, while also providing a second way for the example given above, or if there is something that could match all needs
(I'm writing as I think, hopefully this still makes a bit of sense)
Blair Conrad
@blairconrad

first idea would be to maintain a register of matched calls with the rule that matched.

However, that doesn't make it possible to fulfill all the cases you wanted to have

Yeah, that's my concern.

god you have a lot of interfaces ._.

So. Many. Interfaces. It's the "fluent API tax".

I still don't see a benefit in storing the rule with the call. Mostly because we're not guaranteed to check the same rules as were defined when the call was made.
I think the approach would be essentially walk the recorded calls and test them against the new "rule" we're using in the verification step.