// Test adding recipe with instructions/ingredients/all props and 1 media
        public async Task RecipeAdd_WithAllProperties_Works()
        {
            // each test creates new Connection / Options / DbSchema
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try
            {
                var options = new DbContextOptionsBuilder <RecipesContext>()
                              .UseSqlite(connection)
                              .Options;

                SetupBasicContext(options); // TODO: move into setup?
                int createdRecipeId = -1;
                using (var context = new RecipesContext(options))
                {
                    var service   = new RecipesService(context, this._loggerMock.Object, this._mediaHelper.Object, this._mapper);
                    var newRecipe = new RecipeDto
                    {
                        Description  = "Something",
                        LastModifier = "xx",
                        TitleShort   = "NewRecipe",
                        TitleLong    = "Gorgeous wedding cake",
                        OriginalLink = "https://www.foodnetwork.com/recipes/geoffrey-zakarian/classic-gin-gimlet-2341489",
                        Id           = 5 // should reset to 0 and be assigned by DB
                    };

                    var response = await service.AddOne(newRecipe);

                    Assert.IsTrue(response.Success);
                    var rgx   = new Regex(@"^.*Id:(?<id>[0-9])$");
                    var match = rgx.Match(response.Message);
                    createdRecipeId = Convert.ToInt32(match.Groups["id"].Value);
                }
                using (var context = new RecipesContext(options))
                {
                    var service = new RecipesService(context, this._loggerMock.Object, this._mediaHelper.Object, this._mapper);
                    var recipe  = await service.GetOne(createdRecipeId);

                    Assert.AreEqual("Something", recipe.Description);
                    Assert.AreEqual("xx", recipe.LastModifier);
                    Assert.AreEqual("NewRecipe", recipe.TitleShort);
                    Assert.AreEqual("Gorgeous wedding cake", recipe.TitleLong);
                    Assert.AreEqual("https://www.foodnetwork.com/recipes/geoffrey-zakarian/classic-gin-gimlet-2341489", recipe.OriginalLink);
                }
            }
            finally
            {
                connection.Close();
            }
        }
        public async Task RecipeAdd_WithNullShortTitle_Fails()
        {
            // each test creates new Connection / Options / DbSchema
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            try
            {
                var options = new DbContextOptionsBuilder <RecipesContext>()
                              .UseSqlite(connection)
                              .Options;

                SetupBasicContext(options); // TODO: move into setup?
                using (var context = new RecipesContext(options))
                {
                    var service   = new RecipesService(context, this._loggerMock.Object, this._mediaHelper.Object, this._mapper);
                    var newRecipe = new RecipeDto {
                        Description = "Something", LastModifier = "xx", TitleShort = null
                    };
                    //
                    //Assert.ThrowsAsync<SqliteException>(async () => await service.AddOne(newRecipe));

                    var response = await service.AddOne(newRecipe);

                    Assert.IsFalse(response.Success);
                    Assert.IsTrue(response.Message.Contains("Microsoft.EntityFrameworkCore.DbUpdateException"));
                    Assert.IsTrue(response.Message.Contains("SQLite Error 19"));
                    Assert.IsTrue(response.Message.Contains("NOT NULL constraint failed: recipes.TitleShort"));
                }
            }
            finally
            {
                connection.Close();
            }
        }