I am trying to write some unit tests for my code. In out project we are using the Linq-SQL objects that are created from the DBML. I am trying to figure out how i would need to test the following logic.
Say for example i need to get a count of records from a table using LINQ.
var objectCount = (from x in DB.MyRecords
where x.DateAdded.Date == DateTime.Now.Date
select x).Count(); //For example this will return 4
if(objectCount > 3)
{
//Do some logic here
}
else
{
//Do some logic here
}
Now my understanding is that a unit test is not really a unit test if you access the DB.
My query is also quite more involved than that as it the data structure has Forign keys that need to be maintained.
Now the next problem is that due to the fact that we are using LINQ-SQL object we are not using interfaces therefore we cannot really use a mocking framework (or can we????)
i would like to know what the process is to be able to unit test this.