private Edit ( |
||
commodity | ||
Результат | System.Web.Mvc.ActionResult |
public void Commodity_Edit_Post_InValid_Model_Test() { IUnitOfWork repository = this.MockCommodityRepository; CommodityController target = new CommodityController(repository); Commodity commodity = new Commodity { CommodityID = 1, Name = "aja", LongName = "", CommodityTypeID = 1, ParentID = 1 }; //SetModelError(target); PartialViewResult expected = new PartialViewResult(); ActionResult actual; //Act actual = target.Edit(commodity); PartialViewResult result = actual as PartialViewResult; Assert.IsNotNull(result); }
public void Commodity_Edit_Post_Valid_Model_Test() { IUnitOfWork repository = this.MockCommodityRepository; CommodityController target = new CommodityController(repository); Commodity commodity = new Commodity { CommodityID = 1, Name = "Wheat", LongName = "", CommodityTypeID = 1, ParentID = null }; //SetModelError(target); JsonResult expected = new JsonResult(); ActionResult actual; //Act actual = target.Edit(commodity); JsonResult result = actual as JsonResult; expected.Data = new { success = true }; Assert.AreEqual(expected.Data.ToString(), result.Data.ToString()); }
public void Commodity_Edit_Get_Test() { IUnitOfWork repository = this.MockCommodityRepository; CommodityController target = new CommodityController(repository); int id = 1; ActionResult actual; actual = target.Edit(id); PartialViewResult result = actual as PartialViewResult; Assert.IsNotNull(result); Assert.AreEqual(result.Model.GetType(), typeof(Commodity)); Assert.IsNotNull(result.ViewBag.CommodityTypeID); //major diff between parent and child //Assert.IsNull(result.ViewBag.ParentID); Assert.AreEqual(result.ViewBag.isParent, false); Assert.IsNull(result.ViewBag.CommodityType); Assert.IsNull(result.ViewBag.ParentCommodity); }