I am trying to learn database unit testing from ndbunit tutorial. All is going well. Except I do NOT understand how the author created the CustomerRepository class. Is there a tool that I can point to xsd file in the tutorial and auto generate the repository class? Even if I manually generate it, how would I go about doing it.
Please help.
Thanks
[Test]
public void Test()
{
//I took out some code here...
CustomerRepository repository = new CustomerRepository();
Assert.AreEqual(2, repository.GetAllCustomers().Count);
}
UPDATE
I just used quick entity framework code to do quick data access as follows and it works great..thanks
var context = new MyEntities();
var query = from c in context.Customers select c ;
var count = query.Count();
Assert.AreEqual(2, count);
There is assumption that CustomerRepository is a typical repository class. In your case this is something like
public class CustomerRepository
{
public List<Customer> GetAllCustomers()
{
using (var context = new MyEntities() )
return context.Customers.ToList();
}
}