public void EditValidModel() { //Arrange var controller = new ItemController(new ItemBLL(new ItemServiceStub())); var forventet = new Item { ItemID = 1, ItemCode = "DFGHJ", ItemDesc = "Dette er et kjempebra produkt", Category = 1, ImgPath = "", InStock = 5, Price = 100 }; //Act var actionResult = (RedirectToRouteResult)controller.Edit(forventet); //Assert Assert.AreEqual(actionResult.RouteName, ""); Assert.IsTrue(actionResult.RouteValues.Values.Count == 1); Assert.AreEqual(actionResult.RouteValues.Values.First(), "Index"); }
public void EditGetViewWrongId() { var controller = new ItemController(new ItemBLL(new ItemServiceStub())); //Act var actionResult = (HttpNotFoundResult)controller.Edit(99); Assert.AreEqual(actionResult.StatusCode, 404); }
public void EditModelStateInvalid() { var controller = new ItemController(new ItemBLL(new ItemServiceStub())); var forventet = new Item(); controller.ModelState.AddModelError("ItemDesc", ""); //Act var actionResult = (ViewResult)controller.Edit(forventet); //Assert Assert.IsTrue(actionResult.ViewData.ModelState.Count == 1); Assert.AreEqual(actionResult.ViewName, ""); }
public void EditGetViewPassing() { var controller = new ItemController(new ItemBLL(new ItemServiceStub())); //Act var actionResult = (ViewResult)controller.Edit(1); //Assert Assert.AreEqual(actionResult.ViewName, ""); }