You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an odd issue that may be part my fault, but this seems odd to me, so figured I'd ask about it vs working around it. I'm using Moq 4.8.2 for this test
Basically, I'm testing a class that deals with EntityFramework. The class has a method to return an IEnumerable, which I setup through a Mock DbSet object. Calling it once works, calling it a second time returns 0 elements. Using SetupSequence also doesn't help here. I'm not sure if this is a bug or I'm just missing something with this all.
Below is a linqpad script (relies on Moq and EntityFramework) that describes what I'm seeing:
Using Setup
Before Invocation, total #: 3
First Invocation, total #: 3
Second Invocation, total #: 0
=======
Using SetupSequence (Singular)
Before Invocation, total #: 3
First Invocation, total #: 0
Second Invocation, total #:
=======
Using SetupSequence (Multiple)
Before Invocation, total #: 3
First Invocation, total #: 0
Second Invocation, total #: 0
The text was updated successfully, but these errors were encountered:
Interesting, I changed the line you recommended, and that did indeed solve it. I really appreciate the quick reply, and I think I need to read up on what you mean by "lazy evaluation" in this case - or more accurately what () => ... actually does. The only time I've really used that is when referencing a variable in the expression after the arrow.
Thanks again for the comment, this gives me something to research and try to understand better.
Hi All,
I ran into an odd issue that may be part my fault, but this seems odd to me, so figured I'd ask about it vs working around it. I'm using Moq 4.8.2 for this test
Basically, I'm testing a class that deals with EntityFramework. The class has a method to return an IEnumerable, which I setup through a Mock DbSet object. Calling it once works, calling it a second time returns 0 elements. Using SetupSequence also doesn't help here. I'm not sure if this is a bug or I'm just missing something with this all.
Below is a linqpad script (relies on Moq and EntityFramework) that describes what I'm seeing:
The output of this script is the following:
The text was updated successfully, but these errors were encountered: