private bool RecipeHasExpiredIngredient(RecipeView recipe, IngredientView ingredient) { if (recipe.Ingredients.Contains(ingredient.Title)) { return(ingredient.UseByDate < DateTime.Now); } return(false); }
public void ExpiredUseByIngredientsAreNotIncludedInRecipes() { var useByExpiredIngredient = new IngredientView() { Title = "Ham", BestBefore = "2021-03-25", UseBy = "2020-01-01" }; var useByNotExpiredIngredient = new IngredientView() { Title = "Cheese", BestBefore = "2021-03-25", UseBy = "2021-01-01" }; var lsIngredients = new List <IngredientView>() { useByExpiredIngredient, useByNotExpiredIngredient }; var recipeWExpired = new RecipeView() { Title = "Ham & Cheese Toastie", Ingredients = new List <string>() { "Ham", "Cheese", "Bread", "Butter" } }; var recipeWithoutExpired = new RecipeView() { Title = "Cheese Toastie", Ingredients = new List <string>() { "Cheese", "Bread", "Butter" } }; var lsRecipes = new List <RecipeView>() { recipeWExpired, recipeWithoutExpired }; var ingredientRepo = new TestIngredientRepository(lsIngredients); var recipeRepo = new TestRecipeRepository(lsRecipes); var recipeService = new RecipeService(recipeRepo, ingredientRepo); var result = recipeService.GetRecipes(); Assert.Equal(result.Count, 1); }
/* sets the MVC relationships */ public void createMVC(IngredientModel m, IngredientView v, IngredientController c) { Model = m; View = v; Controller = c; Model.setElement(this); View.setElement(this); Controller.setElement(this); }
public void GetRecipesIfIngredientsMatchTest() { var ingredient1 = new IngredientView() { Title = "Ham", BestBefore = "2021-03-25", UseBy = "2021-01-01" }; var ingredient2 = new IngredientView() { Title = "Cheese", BestBefore = "2021-03-25", UseBy = "2021-01-01" }; var lsIngredients = new List <IngredientView>() { ingredient1, ingredient2 }; var recipe1 = new RecipeView() { Title = "Ham Toastie", Ingredients = new List <string>() { "Ham", "Bread", "Butter" } }; var recipe2 = new RecipeView() { Title = "Rice Toastie", Ingredients = new List <string>() { "Rice", "Butter" } }; var lsRecipes = new List <RecipeView>() { recipe1, recipe2 }; var ingredientRepo = new TestIngredientRepository(lsIngredients); var recipeRepo = new TestRecipeRepository(lsRecipes); var recipeService = new RecipeService(recipeRepo, ingredientRepo); var result = recipeService.GetRecipes(); Assert.Equal(result.Count, 1); }
public override void instantiateElement(Vector3 startPos, Vector3 endPos) { IngredientModel newModel = new IngredientModel(); // instantiate GameObject GameObject newObject = Singletons.Instantiator.instantiateObject(Type); // get the View from GameObject IngredientView newView = newObject.transform.GetComponent <IngredientView>(); // assign MVC so everyone knows each other IngredientController newController = new IngredientController(); this.createMVC(newModel, newView, newController); // update Model values - must be done after MVC is created newModel.Position = endPos; newModel.initModel(); }
//Export the table to a .xls file protected void btn_Export_Click(object sender, EventArgs e) { //Clear output stream Response.ClearContent(); //set filename Response.AppendHeader("content-disposition", "attachment; filename=Ingrediententen.xls"); //setcontenttype Response.ContentType = "application/excel"; //set stringwriter to htmlwriter StringWriter sw = new StringWriter(); HtmlTextWriter htmltw = new HtmlTextWriter(sw); //Write the data to he .xls file IngredientView.RenderControl(htmltw); Response.Write(sw.ToString()); //end Response.End(); }
private void OnManageIngredients(object parameters) { var window = new IngredientView(provider); window.Show(); }
public Ingredient(SymptomChangeList symptomChanges, IngredientView view) { SymptomChanges = symptomChanges; View = view; }
public void BestBeforeOrderingTest() { var ingredient1 = new IngredientView() { Title = "Ham", BestBefore = "2021-03-25", UseBy = "2021-01-01" }; var ingredient2 = new IngredientView() { Title = "Cheese", BestBefore = "2020-01-01", UseBy = "2021-01-01" }; var ingredient3 = new IngredientView() { Title = "Beans", BestBefore = "2021-04-01", UseBy = "2021-01-01" }; var lsIngredients = new List <IngredientView>() { ingredient1, ingredient2, ingredient3 }; var recipe1 = new RecipeView() { Title = "Ham Toastie", Ingredients = new List <string>() { "Ham", "Bread", "Butter" } }; var recipe2 = new RecipeView() { Title = "Cheese Toastie", Ingredients = new List <string>() { "Cheese", "Bread", "Butter" } }; var recipe3 = new RecipeView() { Title = "Beans Toastie", Ingredients = new List <string>() { "Beans", "Bread", "Butter" } }; var lsRecipes = new List <RecipeView>() { recipe1, recipe2, recipe3 }; var ingredientRepo = new TestIngredientRepository(lsIngredients); var recipeRepo = new TestRecipeRepository(lsRecipes); var recipeService = new RecipeService(recipeRepo, ingredientRepo); var result = recipeService.GetRecipes(); var lastRecipe = result[2]; Assert.Equal(recipe2, lastRecipe); }