So in the real world I have something which returns an IEnumerable then an Any query happens to it then some other logic occurs, but I was struggling to mock out the query.
Here is an example of me isolating the use case
[Test]
public void dummy_test()
{
var mockEnumerable = Substitute.For<IEnumerable<int>>();
mockEnumerable.Any(Arg.Any<Func<int, bool>>()).Returns(x => true);
var res = mockEnumerable.Any(x => x == 10);
Assert.That(res, Is.True);
}
So I thought that would be fine, but it just blows up on the stubbing the any field with
System.ArgumentNullException : Value cannot be null.
Parameter name: predicate
I have tried just doing .Any(x => true).ReturnsWithAnyArg(x => true); but that blows up too.
So is there a special way to mock out linq queries on an object?