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); }
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); } }
public CookBookDbContextTests() { _dbContextFactory = new DbContextInMemoryFactory(nameof(CookBookDbContextTests)); _cookBookDbContextSUT = _dbContextFactory.Create(); _cookBookDbContextSUT.Database.EnsureCreated(); }
public CookBookDbContextAsyncTests() { _dbContextFactory = new DbContextInMemoryFactory(nameof(CookBookDbContextTests)); _cookBookDbContextSUT = _dbContextFactory.Create(); }