public void PurchaseOrderLinesController_Edit_GET_isNotValid() { PurchaseOrderLinesController controller = new PurchaseOrderLinesController(); var request = new Mock<HttpRequestBase>(); request.SetupGet(x => x.Headers).Returns(new System.Net.WebHeaderCollection { { "X-Requested-With", "XMLHttpRequest" } }); var context = new Mock<HttpContextBase>(); context.SetupGet(x => x.Request).Returns(request.Object); controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller); HttpNotFoundResult result = controller.Edit(9999999) as HttpNotFoundResult; var expectedResult = new HttpNotFoundResult().GetType(); Assert.IsInstanceOfType(result, expectedResult); }
public void PurchaseOrderLinesController_Edit_GET_isValid() { PurchaseOrderLinesController controller = new PurchaseOrderLinesController(); var request = new Mock<HttpRequestBase>(); request.SetupGet(x => x.Headers).Returns(new System.Net.WebHeaderCollection { { "X-Requested-With", "XMLHttpRequest" } }); var context = new Mock<HttpContextBase>(); context.SetupGet(x => x.Request).Returns(request.Object); controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller); PartialViewResult result = controller.Edit(1) as PartialViewResult; PurchaseOrderLine PurchaseOrderLinesResult = (PurchaseOrderLine)result.Model; Assert.AreEqual(1, PurchaseOrderLinesResult.purchaseOrderLinesID); }