0
我正在創建一個購買網站,該網站將使用MVP和asp.net銷售計算機部件。我試圖在Bussiness層單元測試一個模型,它將使用實體模型將一些值插入到數據庫中。我如何在visual studio中測試這種方法
public class CategoryModelRepsitory : IModelRepository
{
public void Insert(string catName, long catParent)
{
EntityContext con = new EntityContext();
Category cat = new Category();
cat.Name = catName;
cat.Parent = catParent;
con.Category.AddObject(cat);
con.SaveChanges();
}
//other methods like update and delete
}
那麼我該如何測試這個並驗證使用內置的visual studio測試類的期望?
什麼是IDataContext?是我的例子中的EntityContext?如果是我在哪裏定義依賴性?我無法通過vs.net做到這一點嗎? – jim 2012-03-27 09:01:19
檢查這一個: http://thedatafarm.com/blog/data-access/agile-entity-framework-4-repository-part-2-the-repository/ – Ruslan 2012-03-27 09:02:42
我已經保存了該系列,但它沒有提到對任何地方的DI或IoC明確性,我如何在系列的代碼示例中識別它們? – jim 2012-03-27 09:28:26