public void POST_Drink_ShouldReturnNotFoundIfBeerDoesNotExists()
        {
            // Arrange
            var persistenceContext = new FakePersistenceContext();
            var controller = InitializeController(persistenceContext);
            var model = new DrinkBeerViewModel { ID = 0 };

            // Act
            var result = controller.Drink(model);

            // Assert
            result.ShouldBeType<HttpNotFoundResult>();
            persistenceContext.Saved.ShouldBeFalse();
        }
        public void POST_Drink_ShouldNotDecreaseQuantityIfStocksAreAlreadyEmpty()
        {
            // Arrange
            var persistenceContext = new FakePersistenceContext();
            var controller = InitializeController(persistenceContext);
            var beer = TestData.Beers.First();
            var model = new DrinkBeerViewModel { ID = beer.ID };

            beer.Quantity = 0;

            // Act
            var result = controller.Drink(model) as ViewResult;

            // Assert
            persistenceContext.Saved.ShouldBeTrue();
            beer.Quantity.ShouldEqual(0);
        }
        public void Post_Drink_ShouldRedirectToIndex()
        {
            // Arrange
            var controller = InitializeController();
            var model = new DrinkBeerViewModel { ID = TestData.Beers.First().ID };

            // Act
            var result = controller.Drink(model) as RedirectToRouteResult;

            // Assert
            result.RouteValues["action"].ShouldEqual("Index");
        }
        public void POST_Drink_ShouldDecreaseQuantityByOneAndSaveChanges()
        {
            // Arrange
            var persistenceContext = new FakePersistenceContext();
            var controller = InitializeController(persistenceContext);
            var beer = TestData.Beers.First();
            var model = new DrinkBeerViewModel { ID = beer.ID };
            var qtyBefore = beer.Quantity;

            // Act
            var result = controller.Drink(model) as ViewResult;

            // Assert
            persistenceContext.Saved.ShouldBeTrue();
            beer.Quantity.ShouldEqual(qtyBefore - 1);
        }