Ejemplo n.º 1
0
        public void NewIngredient_InsertOrUpdate_IngredientAdded()
        {
            //Arrange
            var ingredient = new IngredientDetailModel()
            {
                Name        = "Water",
                Description = "Mineral water"
            };

            //Act
            ingredient = _ingredientRepositorySUT.InsertOrUpdate(ingredient);

            //Assert
            using var dbxAssert = _dbContextFactory.Create();
            var ingredientFromDb = dbxAssert.Ingredients.Single(i => i.Id == ingredient.Id);

            Assert.Equal(ingredient, IngredientMapper.MapEntityToDetailModel(ingredientFromDb));
        }
Ejemplo n.º 2
0
        public void SeededWater_InsertOrUpdate_IngredientUpdated()
        {
            //Arrange
            var ingredient = new IngredientDetailModel()
            {
                Id          = IngredientSeeds.Water.Id,
                Name        = IngredientSeeds.Water.Name,
                Description = IngredientSeeds.Water.Description,
            };

            ingredient.Name        += "updated";
            ingredient.Description += "updated";

            //Act
            _ingredientRepositorySUT.InsertOrUpdate(ingredient);

            //Assert
            using var dbxAssert = _dbContextFactory.Create();
            var ingredientFromDb = dbxAssert.Ingredients.Single(i => i.Id == ingredient.Id);

            Assert.Equal(ingredient, IngredientMapper.MapEntityToDetailModel(ingredientFromDb));
        }
Ejemplo n.º 3
0
        public void GetById_SeededWater()
        {
            var ingredient = _ingredientRepositorySUT.GetById(IngredientSeeds.Water.Id);

            Assert.Equal(IngredientMapper.MapEntityToDetailModel(IngredientSeeds.Water), ingredient);
        }