Ejemplo n.º 1
0
        public void AddNew_Ingredient_Persisted()
        {
            //Arrange
            var ingredientEntity = new IngredientEntity("Salt", "Mountain salt");

            //Act
            _cookBookDbContextSUT.Ingredients.Add(ingredientEntity);
            _cookBookDbContextSUT.SaveChanges();


            //Assert
            using var dbx = _dbContextFactory.Create();
            var retrievedIngredient = dbx.Ingredients.Single(entity => entity.Id == ingredientEntity.Id);

            Assert.Equal(ingredientEntity, retrievedIngredient);
        }
        public void AddNew_Ingredient_Persisted()
        {
            //Arrange
            var ingredientEntity = new IngredientEntity
            {
                Name = "Salt",
                Description = "Mountain salt",
                ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Salt_shaker_on_white_background.jpg/800px-Salt_shaker_on_white_background.jpg"
            };

            //Act
            _cookBookDbContextSUT.Ingredients.Add(ingredientEntity);
            _cookBookDbContextSUT.SaveChanges();


            //Assert
            using var dbx = _dbContextFactory.Create();
            var retrievedIngredient = dbx.Ingredients.Single(entity => entity.Id == ingredientEntity.Id);
            Assert.Equal(ingredientEntity, retrievedIngredient);
        }
Ejemplo n.º 3
0
        public void AddNew_Ingredient_Persisted()
        {
            //Arrange
            var ingredientEntity = new IngredientEntity
            {
                Name        = "Salt",
                Description = "Mountain salt"
            };

            //Act
            _cookBookDbContextSUT.Ingredients.Add(ingredientEntity);
            _cookBookDbContextSUT.SaveChanges();


            //Assert
            using (var dbx = _dbContextFactory.Create())
            {
                var retrievedIngredient = dbx.Ingredients.Single(entity => entity.Id == ingredientEntity.Id);
                Assert.Equal(ingredientEntity, retrievedIngredient, IngredientEntity.DescriptionNameIdComparer);
            }
        }
Ejemplo n.º 4
0
 public CookBookDbContextTests()
 {
     _dbContextFactory     = new DbContextInMemoryFactory(nameof(CookBookDbContextTests));
     _cookBookDbContextSUT = _dbContextFactory.Create();
     _cookBookDbContextSUT.Database.EnsureCreated();
 }
Ejemplo n.º 5
0
 public CookBookDbContextAsyncTests()
 {
     _dbContextFactory     = new DbContextInMemoryFactory(nameof(CookBookDbContextTests));
     _cookBookDbContextSUT = _dbContextFactory.Create();
 }