public async Task Delete_from_Collection() { //Arrange var recipe1 = await AddRecipe(); SavedRecipes savedRecipe1 = new SavedRecipes { IdRecipe = recipe1.Id, IdUser = AuthenticatedUserId }; await ExecuteDatabaseAction(async (tastyBoutiqueContext) => { await tastyBoutiqueContext.AddAsync(savedRecipe1); tastyBoutiqueContext.SaveChanges(); }); //Act var response = await HttpClient.DeleteAsync($"api/v1/collections/{recipe1.Id}"); //Assert savedRecipe1 = null; await ExecuteDatabaseAction(async (tastyBoutiqueContext) => { savedRecipe1 = await tastyBoutiqueContext.SavedRecipes .FirstOrDefaultAsync(sr => sr.IdRecipe == recipe1.Id && sr.IdUser == AuthenticatedUserId); }); savedRecipe1.Should().BeNull(); }
public async Task Add_to_Collection() { //Arrange var recipe = await AddRecipe(); var model = new SavedRecipeModel { IdRecipe = recipe.Id }; //Act var response = await HttpClient.PostAsJsonAsync($"api/v1/collections", model); //Assert response.IsSuccessStatusCode.Should().BeTrue(); SavedRecipes savedRecipe = null; await ExecuteDatabaseAction(async (tastyBoutiqueContext) => { savedRecipe = await tastyBoutiqueContext.SavedRecipes .FirstOrDefaultAsync(sr => sr.IdUser == AuthenticatedUserId && sr.IdRecipe == recipe.Id); }); savedRecipe.Should().NotBeNull(); }