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 fails when a method with input parameter of type Expression<Func<T,bool>> is called #1288

Closed
Arulselvan2408 opened this issue Sep 22, 2022 · 1 comment

Comments

@Arulselvan2408
Copy link

When a method with input parameters of type Expression<Func<T,bool>>, the mock setup is not returning the expected value when called inside using statement with transaction inside the using statement.
Let' say my expression is x=>x.Userid==userid where userid is an input parameter of the test method

mock.SetUp(x=>x.SearchFor(expression)).Returns(some expected value).Callback(()=>++counter)

This setup works outside the transaction scope and increases the callback but when I call inside the transaction it do not increase the callback. Upon Debugging when I call inside the transaction the expression value changes to {(t.UserId == value( DisplayClass29_1).CS$<>8__locals1.userId)}

here .CS$<>8__locals1 is added extra to the expression.

FYR
When I call the same method outside transaction {(t.UserId == value(DisplayClass29_0).userId)} looks like this

@stakx
Copy link
Contributor

stakx commented Dec 12, 2022

Closing this issue since no repro code was provided. @Arulselvan2408, if you do have (minimally complete) repro code, please post it and I'll take another look.

@stakx stakx closed this as completed Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants