public void AddPurchaseOrderTest() { var purdet = new PurchaseDetail(); var _order = new PurchaseHeader(); var dets = new List<PurchaseDetail>(); dets.Add(purdet); _order.purchaseDetail = dets.AsQueryable(); mockPurchaseRepository.Setup(x => x.Add(It.IsAny<PurchaseOrderHeader>())); purcService.AddPurchaseOrder(_order); mockPurchaseRepository.Verify(x => x.Add(It.IsAny<PurchaseOrderHeader>())); }
public void Edit_Action_Returns_Create_View_WithValid_Model() { //arrange var header = new PurchaseHeader(); var detail = new PurchaseDetail(); var dets = new List<PurchaseDetail>(); dets.Add(detail); header.purchaseDetail =dets.AsQueryable() ; mockservice.Setup(x => x.GetPurchaseOrder(1)).Returns(header); //act var result = _purchasecontroller.Edit(1); //assert result.AssertViewRendered().ForView("Create"); result.AssertViewRendered().WithViewData<PurchaseHeaderModel>(); }
public void Details_Get_Action_Returns_Details_View_WithValid_Model() { //arrange var header = new PurchaseHeader(); var detail = new PurchaseDetail(); var dets = new List<PurchaseDetail>(); dets.Add(detail); header.purchaseDetail = dets.AsQueryable(); mockservice.Setup(x => x.GetPurchaseOrder(1)).Returns(header); var model = StubPurchaseHeaderModel.ValidModel(); model.PurchaseOrderID = 1; //act var result = _purchasecontroller.Details(1); //assert result.AssertViewRendered().ForView("Details"); result.AssertViewRendered().WithViewData<PurchaseHeaderModel>(); Assert.IsInstanceOfType(result.AssertViewRendered().Model, typeof(PurchaseHeaderModel)); mockservice.Verify(x => x.GetPurchaseOrder(1)); }