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
In reference to this question I asked on Stack Overflow, We're attempting to verify that a specific LINQ query was ran against a mock, but it fails no matter what we do. If I abridge the code being tested to the following:
The Assert.IsNotNull passes but the ActivitiesMock.Verify doesn't with the following error:
Test method Example.Tests.Backend.Repositories.ActivityRepositoryTests.GetDoesThings threw exception:
Moq.MockException:
Expected invocation on the mock at least once, but was never performed: x => x.Where(y => y.ID == .ID)
Configured setups:
x => x.Where(It.IsAny<Expression`1>()), Times.Once
Performed invocations:
IAppCollection`2.Where(x => (x.ID == value(Example.Backend.Repositories.ActivityRepository+<>c__DisplayClass2_0).ID))
Are we setting up a test incorrectly, are we expecting Moq to handle something it can't, or is this a bug in Moq?
The text was updated successfully, but these errors were encountered:
Looks like it's because of the DisplayClass. Unless there's a recommendation on how to get them to compare, we're going with storing the Expression as part of the Returns statement then compiling and invoking the predicate against things that should and shouldn't match and asserting it the result is true or false.
In reference to this question I asked on Stack Overflow, We're attempting to verify that a specific LINQ query was ran against a mock, but it fails no matter what we do. If I abridge the code being tested to the following:
And run the following test:
The
Assert.IsNotNull
passes but theActivitiesMock.Verify
doesn't with the following error:Are we setting up a test incorrectly, are we expecting Moq to handle something it can't, or is this a bug in Moq?
The text was updated successfully, but these errors were encountered: