我正在尝试从ndbunit教程中学习数据库单元测试。一切都很顺利。但我不明白作者是如何创建CustomerRepository类的。有工具可以指向教程中的xsd文件并自动生成存储库类吗?即使我手动生成它,我将如何去做它。
请帮帮忙。
谢谢
[Test]
public void Test()
{
//I took out some code here...
CustomerRepository repository = new CustomerRepository();
Assert.AreEqual(2, repository.GetAllCustomers().Count);
}更新
我只是使用快速实体框架代码进行快速数据访问,如下所示,它运行great..thanks
var context = new MyEntities();
var query = from c in context.Customers select c ;
var count = query.Count();
Assert.AreEqual(2, count);发布于 2012-05-02 21:49:01
假设CustomerRepository是一个典型的存储库类。在你的例子中,这就像是
public class CustomerRepository
{
public List<Customer> GetAllCustomers()
{
using (var context = new MyEntities() )
return context.Customers.ToList();
}
}https://stackoverflow.com/questions/10421891
复制相似问题