public bool UpdateUserDataDictionary(Dictionary <string, string> userData) { User user = _getUpdatedUserFromDictionary(userData); _repo.UpdateUserAuth0Data(user); return(true); }
public async Task TestRecipeSaving() { // var tag = new Recipe() { TagId = 123, TagName = "Cheese" }; var sentrecipe = new SentRecipe(); var date = DateTime.Now; sentrecipe.DateCreated = date; sentrecipe.DateLastPrepared = date; Tag t = new Tag() { TagName = "tag name 2" }; Ingredient i = new Ingredient() { IngredientName = "ing name 2" }; Step s = new Step() { StepDescription = "new description", RecipeStepNo = 1 }; sentrecipe.ingredients = new List <Ingredient>() { new Ingredient() { IngredientName = "ingredient name" } }; sentrecipe.tags = new List <Tag>() { new Tag() { TagName = "tag name" } }; Step s1 = new Step() { StepDescription = "step description" }; sentrecipe.Steps = new List <Step>() { s1 }; User user = new User() { Auth0 = "authcode", Firstname = "fname", Lastname = "lname", DateCreated = date, Email = "email", ImageUrl = "picture" }; AuthModel model = new AuthModel() { Sub = "authcode", FirstName = "fname", LastName = "lname", Email = "email", ProfileImage = "picture", Username = "******" }; Dictionary <string, string> userDictionary = new Dictionary <string, string>(); userDictionary["email"] = "email"; userDictionary["picture"] = "picture"; userDictionary["sub"] = "authcode"; bool result; Recipe recipe = null; using (var context = new InTheKitchenDBContext(testOptions)) { context.Database.EnsureDeletedAsync(); context.Database.EnsureCreatedAsync(); var repo = new KitchenRepository(context); var msr = new KitchenLogic(context, repo); var reviewlogic = new ReviewStepTagLogic(context, repo); var userlogic = new UserLogic(context, repo); userlogic.UpdateUser(model, userDictionary); userlogic.UpdateUser(model, userDictionary); var sr = await msr.saveRecipe(sentrecipe, model.Sub); sentrecipe.tags.Add(t); sentrecipe.ingredients.Add(i); sentrecipe.Steps.Add(s); sentrecipe.Steps.Remove(s1); sr = await msr.saveRecipe(sentrecipe, model.Sub); recipe = repo.GetRecipeById(sr.RecipeId); repo.UpdateUserAuth0Data(user); var rev = new Review() { Recipe = recipe, ReviewDate = date, ReviewDescription = "review description", RecipeId = recipe.RecipeId, }; reviewlogic.addReview(userDictionary["sub"], rev); HistoryModel hmodel = new HistoryModel() { recipeId = recipe.RecipeId, sub = model.Sub }; msr.SaveRecipePrepare(hmodel); } Assert.Equal(recipe.RecipeTags.ToArray()[0].Tag.TagName, "tag name"); }