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"));
        }
示例#2
0
        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();
        }
示例#3
0
        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);
        }
示例#4
0
 public ActionResult UpdateBeer(ManageBeerViewModel model)
 {
     this.service.UpdateBeer(model);
     return(this.RedirectToAction("ManageBeers"));
 }
示例#5
0
        public ActionResult ManageBeer(int id)
        {
            ManageBeerViewModel model = this.service.GetBeerById(id);

            return(this.View(model));
        }