My current solution is to create a class that has my service/data business logic, test that with a local db (mdf) and then wrap that class with identical functions from the data service class.
public class MyDataService : DataService<MyEntities>
{
[WebGet]
[SingleResult]
public Team GetTeam(string name)
{
return _serviceBusinessLogic.GetTeam(name);
}
}
//seam here to make this testable
public class ServiceBusinessLogic
{
public Team GetTeam(string name)
{
return _dbContext.Teams.SingleOrDefault(p => p.Name == name);
}
}
But since they are identical, there should be no need for the wrapper functions.
I would like to test the data services directly, but there is no way for me to set the DataSource since CreateDataSource is protected.
public class MyDataService : DataService<MyEntities>
{
[WebGet]
[SingleResult]
public Team GetTeam(string name)
{
//problem is CurrentDataSource is not settable, so cant set it in test
return CurrentDataSource.Teams.SingleOrDefault(p => p.Name == name);
}
}