我读了这篇关于模拟 Entity Framework(EF) 的帖子。
我们不应该也抽象实体的类型吗?为了保持数据访问层 (DAL) 和业务层 (BL) 之间的解耦?
在上面的帖子中,他使用了 EF 具体生成的实体类型:
[TestMethod]
public void GetCustomer()
{
ContextContainerMock container = new ContextContainerMock();
IMyEntities en = container.Current;
**Customer c = new Customer { ID = 1, FirstName = "John", LastName = "Doe" };**
en.Customers.AddObject(c);
CustomerService service = new CustomerService(container);
var a = service.GetCustomer(1);
Assert.AreEqual(c.FirstName, a.FirstName);
Assert.AreEqual(c.LastName, a.LastName);
}