public async Task AddNew_Ingredient_Persisted()
        {
            //Arrange
            IngredientEntity?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);
            await _cookBookDbContextSUT.SaveChangesAsync();

            //Assert
            await using CookBookDbContext? dbx = _dbContextFactory.CreateDbContext();
            IngredientEntity?retrievedIngredient = await dbx.Ingredients.SingleAsync(entity => entity.Id == ingredientEntity.Id);

            Assert.Equal(ingredientEntity, retrievedIngredient);
        }
Beispiel #2
0
 public CookBookDbContextTests()
 {
     _dbContextFactory     = new DbContextInMemoryFactory(nameof(CookBookDbContextTests));
     _cookBookDbContextSUT = _dbContextFactory.CreateDbContext();
     _cookBookDbContextSUT.Database.EnsureCreated();
 }
Beispiel #3
0
 public CookBookDbContextFixture()
 {
     DbContextFactory     = new DbContextInMemoryFactory(typeof(TFixture).Name);
     CookBookDbContextSUT = DbContextFactory.CreateDbContext();
     CookBookDbContextSUT.Database.EnsureCreated();
 }
 public CookBookDbContextAsyncTests()
 {
     _dbContextFactory     = new DbContextInMemoryFactory(nameof(CookBookDbContextTests));
     _cookBookDbContextSUT = _dbContextFactory.CreateDbContext();
 }