Using Rhino Mocks:
var list = MockRepository.GenerateMock<List<Foo>>();
list.Expect(e => e.Any(Arg<Func<Foo, bool>>.Is.Anything)).Return(false);
It throws
ArgumentNullException: Value cannot be null. Parameter name: predicate
How do I write this well?
The method Any
is an Extension
method which means the method is a static
method. You cannot fake static
methods using Rhino Mocks
.
It's a common mistake to put an expectation like this for asserting.
Actually you don't have to fake the List
(It is a DS which means the behaviour won't impact the test), just create an instance of the real class and use it , then verify that the flow of empty list behave correctly.(do Assert
on the things which should be happen)