So a coworker and I are in a fairly heated debate. We are beginning a new project and we are attempting to use BDD. We are both first-timers and don't fully understand what practices should be used. We've written some specs and we are now implementing the code. Things are getting pretty tricky since there is a lot of database interaction. We are stuck on how we should mock our data. The method we were going about would require us to mock our methods instead of our data. It's easiest if I show you in code...
public static void AssignLeadToDistributor(int leadId, int distributorId)
{
Lead lead = GetById(leadId);
lead.DistributorId = distributorId;
Save(lead);
}
Basically, we would have to override GetById() and Save() to return mock data for us to test this. It seems to make more sense to do it like this:
public static void AssignLeadToDistributor(Lead lead, Distributor distributor)
{
lead.DistributorId = distirbutor.Id;
}
Then we could just mock our objects.
Clearly the second method makes it easier to test. However, the argument is that we don't want to have to fetch a new lead and distributor object on our front end code, because it would be easier to just pass the ids of our objects. Cutting down on the actual code in our front end.
Hopefully I explained that well enough.
What do you guys think? Which way makes more sense?