I have spent some time trying to understand the topic of unit testing as it relates to using EF 5.0/DbContext. The function below is the one to unit test. From my basic understanding it seems I have the following options.
I create a repository interface. One is the real implementation and the other is the fake one. The fake one would use data I would create from the entity objects. In this case I could create a List... but the problem seems to be that linq->objects (the test) is not the same as linq->EF so im not really testing anything ?
Create a small testing DB somehow using the information from the DBContext.. and then add the data to the DB and retrieve it.. though not sure how I would do that. how do I get a DB created from my Dbcontext as part of a MSunit test run ?
Do not need to unit test. It is really just testing the 'Where' extension method of the EF context?
So.. can someone explain the proper way to think about this without getting too advanced? I understand the basic concepts of unit testing repository pattern when you are calling them from MVC controllers which are most demos.
public class MSAManager// : IMSAManager
{
private MATT_LocalStatisticsEntities context = new MATT_LocalStatisticsEntities();
//Takes series of FIPS codes and sees if they exist in the DB
public bool IsPlaceExistsV1(string FIPS_SMA, string FIPS_StateCode, string FIPS_CountyCode, string FIPS_EntityCode, DateTime year)
{
var duplicate = context.Places.Where(x => ((x.FIPSMSA == FIPS_SMA) &&
(x.FIPSState == FIPS_StateCode) &&
(x.FIPSCounty == FIPS_CountyCode) &&
(x.FIPSEntity == FIPS_EntityCode) &&
(x.StartDate == year)
));
return (duplicate.Count() != 0);
}