Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moq.Verify cant detect Invocation when a method is passed #1225

Closed
evilc0 opened this issue Dec 11, 2021 · 1 comment · Fixed by #1232
Closed

Moq.Verify cant detect Invocation when a method is passed #1225

evilc0 opened this issue Dec 11, 2021 · 1 comment · Fixed by #1232
Labels
Milestone

Comments

@evilc0
Copy link

evilc0 commented Dec 11, 2021

Hello,

first of all, thank you very much for this masterpeace of software.

I think i found a bug in the verification of mocks, i assume that it is coming from late time binding of parameter invocation, but its just a assumtation.

Moq.Verify(m => m.MyMethod(Convert.FromBase64String(myArr)) wont match.

Moq.MockException : 
Expected invocation on the mock at least once, but was never performed: m => m.Transmit(1, [1, 2, 3], It.IsAny<byte[]>())

Performed invocations:

   Mock<IHardware:3> (m):

      IHardware.Transmit(1, [1, 2, 3], [0, 0, 0, 0, 0, 0, 0, 0])

I've created a minimal repo to reproduce the problem:

https://github.com/evilc0/MoqBug

@stakx
Copy link
Contributor

stakx commented Feb 12, 2022

Hi @evilc0, I've taken a look. There is indeed an inconsistency in how Moq matches enumerable values (such as your byte[] arrays), depending on whether they are passed directly (as a constant) or returned from a method call. The PR linked above should rectify this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants