Argument constraints in RhinoMock methods
- by Khash
I am mocking a repository that should have 1 entity in it for the test scenario. The repository has to return this entity based on a known id and return nothing when other ids are passed in.
I have tried doing something like this:
_myRepository.Expect(item => item.Find(knownId)).Return(knownEntity);
_myRepository.Expect(item => item.Find(Arg<Guid>.Is.Anything)).Return(null);
It seems however the second line is overriding the first and the repository always returns null. I don't want to mock all the different possible IDs asked (they could go up to hundreds) when the test scenario is only concerned with the value of one Id.