Reputation: 31800
I have tried the following:
var getAllResponse = new GetAllResponse();
// Prime the GetAll method
var mockILineOfBusinessService = MockRepository.GenerateMock<ILineOfBusinessService>();
mockILineOfBusinessService.Expect(i => i.GetAll(new GetAllRequest())).Return(getAllResponse);
This is from the class I am testing:
public static string GetTeamForFocusArea(this ILineOfBusinessService lineOfBusinessService)
{
...
GetAllResponse response = lineOfBusinessService.GetAll(new GetAllRequest());
...
}
In the above example the response type is always equal to null after the call to GetAll()
Could anyone point me in the right direction pls?
Upvotes: 0
Views: 35
Reputation: 14697
You're defining an expectation that when GetAll() is executed with a specific instance of GetAllRequest, you'll return the getAllResponse you earlier set up. However, inside your GetTeamForFocusArea call, you're making a call to GetAll with a totally different instance of GetAllRequest (it's the one you're creating at that time). Since the instances don't match, Rhino.Mocks sees this as a different call and doesn't return your expectation.
Set up your expectation to IgnoreArguments() since it appears you don't care what is passed to GetAll, you just want it to return a specific result.
Upvotes: 1