Пример #1
0
        public ActionResult AddIngredienser(IngredientViewModel ingredientViewModel)
        {
            var isStored = _dbSimulator.StoreData(ingredientViewModel);

            if (isStored)
            {
                ingredientViewModel= new IngredientViewModel
                {
                    IsStored = true
                };
            }
            else
            {
                ingredientViewModel.IsStored = false;
            }

            return View(ingredientViewModel);
        }
Пример #2
0
        public void IngredienseStoredInDd()
        {
            var dataBaseSimulator = Substitute.For<IDataBaseSimulator>();
            dataBaseSimulator.StoreData(Arg.Any<IngredientViewModel>()).Returns(true);

            var adminController = new AdminController(dataBaseSimulator);

            var ingredientViewModel = new IngredientViewModel
            {
                Substance = "Coke", Units = Unit.L
            };

            var result = adminController.AddIngredienser(ingredientViewModel) as ViewResult;
            if (result != null)
            {
                var viewModel = (IngredientViewModel)result.ViewData.Model;
                Assert.IsTrue(viewModel.IsStored, "isStored");
                Assert.IsNull(viewModel.Substance,"Substance");
                Assert.AreEqual(viewModel.Units,Unit.Dl);
            }
        }
Пример #3
0
        public void IngredienseIsNotStoredInDd()
        {
            //Arrange
            var dataBaseSimulator = Substitute.For<IDataBaseSimulator>();
            dataBaseSimulator.StoreData(Arg.Any<IngredientViewModel>()).Returns(false);

            var adminController = new AdminController(dataBaseSimulator);

            var ingredientViewModel = new IngredientViewModel
            {
                Substance = "Coke",
                Units = Unit.L
            };

            //Act
            var result = adminController.AddIngredienser(ingredientViewModel) as ViewResult;
            
            //Assert
            var viewModel = (IngredientViewModel) result.ViewData.Model;
            Assert.IsFalse(viewModel.IsStored, "inNotStored");
            Assert.AreEqual(viewModel.Substance, "Coke", "Substance");
            Assert.AreEqual(viewModel.Units, Unit.L, "units");
        }
Пример #4
0
        private void StoreInToDatabase(IngredientViewModel ingredientViewModel)
        {

        }