Search code examples
c#mockinglambdarhino-mocks

Mocking lambda in rhino mocks


I am trying to use Rhino Mocks to mock the following lambda, but keep hitting a brick wall

var result = rep.Find<T>(x => (x as IEntity).ID == (entity as IEntity).ID).FirstOrDefault();

Any ideas?


Solution

  • Found the answer I was after

    repository.Expect(action => action.Find<Entity>(x => x.ID == 0))
              .IgnoreArguments()
              .Return(entities)
              .Repeat
              .Any();