Ejemplo n.º 1
0
        public async Task AddIngredientAsyncAdds()
        {
            var options = new DbContextOptionsBuilder <Project2JAGVContext>()
                          .UseInMemoryDatabase("AddIngredientAsyncAdds")
                          .Options;

            Ingredient ingredient = new Ingredient
            {
                Id             = 1,
                TypeId         = 1,
                Name           = "name",
                Price          = 1,
                IngredientType = new IngredientType
                {
                    Id   = 1,
                    Name = "name",
                }
            };

            using var actContext = new Project2JAGVContext(options);
            var repo = new DataAccess.DataAccess(actContext, new MapperStub());

            await repo.AddIngredientAsync(ingredient);

            await repo.SaveAsync();

            using var arrangeContext = new Project2JAGVContext(options);
            var result = arrangeContext.Ingredients;

            Assert.NotNull(result);
        }