private DeleteConfirmed ( int id ) : System.Web.Mvc.ActionResult | ||
id | int | |
리턴 | System.Web.Mvc.ActionResult |
public void Commodity_Delete_Confirmed_Success_Test() { IUnitOfWork repository = this.MockCommodityRepository; CommodityController target = new CommodityController(repository); //Commodity commodity = new Commodity //{ // Name = "Gebse", // LongName = "", // CommodityTypeID = 1, // ParentID = 1 //}; int id = 6; //delete the child yellow wheat commodity int commodityPreCount = this.MockCommodityRepository.Commodity.GetAll().Count; Assert.AreEqual(5, commodityPreCount); JsonResult expected = new JsonResult(); ActionResult actual; const string testUrl = "/Commodity"; //Act actual = target.DeleteConfirmed(id); RedirectToRouteResult result = actual as RedirectToRouteResult; //the number of commodities should decrease by 1 int commodityPostCount = this.MockCommodityRepository.Commodity.GetAll().Count; Assert.AreEqual(commodityPreCount - 1, commodityPostCount); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
public void Commodity_Delete_Confirmed_Faliure_Test() { IUnitOfWork repository = this.MockCommodityRepository; CommodityController target = new CommodityController(repository); Commodity commodity = new Commodity { Name = "Gebse", LongName = "", CommodityTypeID = 1, ParentID = null }; int id = 1; //delete the wheat commodity int commodityPreCount = this.MockCommodityRepository.Commodity.GetAll().Count; Assert.AreEqual(5, commodityPreCount); JsonResult expected = new JsonResult(); ActionResult actual; //Act actual = target.DeleteConfirmed(id); ViewResult result = actual as ViewResult; //the number of commodities should decrease by 1 int commodityPostCount = this.MockCommodityRepository.Commodity.GetAll().Count; Assert.AreEqual(commodityPreCount, commodityPostCount); Assert.AreEqual(result.ViewBag.ERROR,true); Assert.IsNotNull(result.ViewBag.ERROR_MSG); }