public void TestUpdatingIngredients() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var r = new Recipe("Honey Buttermilk Bread"); var i = new Ingredient("Flour", "6 cups") { recipeId = 1, ingredientId = 1 }; var i2 = new Ingredient("Bread Flour", "6 1/3 cups") { recipeId = 1, ingredientId = 1 }; i = i2; t.initializeDatabase(); dbR.InsertRecipe(r); dbI.insertIngredient(i, r); dbI.UpdateIngredient(i); var myIngredientBox = dbI.queryAllIngredientsFromIngredientTable(); Assert.AreEqual(i2.name, myIngredientBox[0].name); Assert.AreEqual(i2.measurement, myIngredientBox[0].measurement); }
public void TestInsertIngredientToIngredientDatabase() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var r = new Recipe("Cranberry Swirl Bread") { id = 1 }; var i = new Ingredient("Cranberries", "2 cups") { recipeId = r.id }; t.initializeDatabase(); dbR.InsertRecipe(r); dbI.insertIngredient(i, r); var myRecipeBox = dbR.queryRecipes(); var myIngredientBox = dbI.queryAllIngredientsFromIngredientTable(); var myRecipe = dbR.GetFullRecipeAndFullIngredientsForRecipe(r); Assert.AreEqual(r.name, myRecipeBox[0].name); Assert.AreEqual(i.name, myIngredientBox[0].name); Assert.AreEqual(i.measurement, myIngredientBox[0].measurement); Assert.AreEqual(i.name, myRecipe.ingredients[0].name); Assert.AreEqual(i.measurement, myRecipe.ingredients[0].measurement); }
public void TestIngredientTable() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var i = new Ingredient("all-purpose flour", "2 1/2 cups") { recipeId = 1 }; var i2 = new Ingredient("butter", "1/2 cup") { recipeId = 1 }; var r = new Recipe("White Cake") { id = 1 }; t.initializeDatabase(); dbR.InsertRecipe(r); dbI.insertIngredient(i, r); dbI.insertIngredient(i2, r); var recipes = dbR.queryRecipes(); var ingredients = dbI.queryAllIngredientsFromIngredientTable(); var myIngredientBox = dbI.queryAllIngredientsFromIngredientTable(); Assert.AreEqual("all-purpose flour", ingredients[0].name); Assert.AreEqual("butter", ingredients[1].name); }
public void TestHersheysUnsweetenedCocoa() { var t = new DatabaseAccess(); var dbR = new DatabaseAccessRecipe(); var dbI = new DatabaseAccessIngredient(); var r = new Recipe("Chocolate Something") { id = 1 }; var i = new Ingredient("Hershey's Special Dark Cocoa") { recipeId = 1, ingredientId = 1, sellingWeight = "8 oz", measurement = "1/2 cup", density = 4.16m }; t.initializeDatabase(); dbR.InsertRecipe(r); t.insertIngredientIntoAllTables(i, r); dbI.getIngredientMeasuredPrice(i, r); var myIngInfo = dbI.queryAllIngredientsFromIngredientTable(); var myRecipesInfo = dbR.queryRecipes(); Assert.AreEqual(1, myRecipesInfo.Count()); Assert.AreEqual(.87m, myIngInfo[0].priceOfMeasuredConsumption); }
//so, if we're searching for something, it's not in our database... //it may share a type, but it's not in the database... //so when i search for it, i can give the user what i think the name, the selling weigh, the selling price, type and classificatoin (i could provide a list of classifications too, similar to my density text database... //so, first give a list of the name, sellingweight, sellingprice, priceperounce, type, density, classification... //if the user confirms that the information is correct and gives the measurement, then i can add the ingredient (i should be able to call updatealltables... it should check to make sure i have if the ingredients table doesn't have this ingredient to insert the ingredient //i should also have a form that allows hte user to create a short name for it (eg: instead of King Arthur Bread Flour, the short name can be Bread Flour that the user inputs...) //let's get the other views working first... public ActionResult CreateRecipe(string recipeTitle) { recipeTitle = recipeTitle.Trim(); Recipe newrecipe = new Recipe(recipeTitle); var db = new DatabaseAccessRecipe(); db.InsertRecipe(newrecipe); return(Redirect("/home/RecipeBox")); }