public void UpdateBeerShouldRedirectToActionManageBeers() { var controller = new AdminController(mockedService.Object); var model = new ManageBeerViewModel(); controller.WithCallTo(c => c.UpdateBeer(model)) .ShouldRedirectTo <AdminController>(typeof(AdminController).GetMethod("ManageBeers")); }
public void UpdateBeer(ManageBeerViewModel model) { var beer = this.db.Beers.FindFirst(b => b.Id == model.Id); beer.IsDeleted = model.IsDeleted; beer.Manufacturer = (BeerMake)Enum.Parse(typeof(BeerMake), model.Manufacturer); beer.EndOfSerialNumber = model.EndOfSerialNumber; this.db.SaveChanges(); }
public void UpdateBeerShouldMakeChanges() { string modifiedSerialNumber = "11111"; int beerId = 1; ManageBeerViewModel model = new ManageBeerViewModel { Id = beerId, EndOfSerialNumber = modifiedSerialNumber, HidersUsername = "******", IsDeleted = false, Manufacturer = "Ariana" }; this.adminService.UpdateBeer(model); Assert.AreEqual(modifiedSerialNumber, this.db.Beers.FindFirst(b => b.Id == beerId).EndOfSerialNumber); }
public ActionResult UpdateBeer(ManageBeerViewModel model) { this.service.UpdateBeer(model); return(this.RedirectToAction("ManageBeers")); }
public ActionResult ManageBeer(int id) { ManageBeerViewModel model = this.service.GetBeerById(id); return(this.View(model)); }