public void UpdatePurchaseTest() { IPurchaseRepository repo = new PurchaseRepository(); // IUnitOfWork unit = new UnitOfWork(); // IPurchaseRepository repo = new PurchaseRepository(unit); var header = repo.Single(x => x.VendorID == 1699); Assert.IsNotNull(header); header.VendorID = 1700; var details = header.PurchaseOrderDetails.Where(x => x.ProductID == 999).AsQueryable(); Assert.IsNotNull(details); var detail = details.FirstOrDefault(); detail.ProductID= 997; detail.OrderQty = 300; var newdet = new PurchaseOrderDetail(); newdet.DueDate = DateTime.Now.Date; newdet.ModifiedDate = DateTime.Now.Date; newdet.LineTotal = 10; newdet.OrderQty = 10; newdet.ProductID = 999; newdet.PurchaseOrderID = header.PurchaseOrderID; newdet.ReceivedQty = 0; newdet.RejectedQty = 0; newdet.StockedQty = 0; newdet.UnitPrice = 10; header.PurchaseOrderDetails.Add(newdet); header.PurchaseOrderDetails.Add(new PurchaseOrderDetail() { DueDate = DateTime.Now.Date , OrderQty = 25 , ProductID = 998 , UnitPrice = 600 , LineTotal = 700 , ReceivedQty = 25 , RejectedQty = 0 , StockedQty = 0 , ModifiedDate = DateTime.Now.Date }); repo.Attach(header); header = repo.Single(x => x.VendorID == 1700); Assert.IsNotNull(header); details = header.PurchaseOrderDetails.Where(x => x.ProductID == 997).AsQueryable(); Assert.IsNotNull(details); //var pocoDept = Mapper.Map<Department, dDepartment>(department); //return pocoDept; }