public void Test_GetCategories_ReturnsAllRecipeCategories() { //Arrange Recipe testRecipe = new Recipe("Mac and cheese", "cheese and noodles", "cook it", 5); testRecipe.Save(); Category testCategory1 = new Category("Mexican"); testCategory1.Save(); Category testCategory2 = new Category("Thai"); testCategory2.Save(); //Act testRecipe.AddCategory(testCategory1); List <Category> result = testRecipe.GetCategories(); List <Category> testList = new List <Category> { testCategory1 }; //Assert Assert.Equal(testList, result); }
public void AddTag_AddTagsToOneRecipe_True() { //Arrange Recipe testRecipe = new Recipe("Soup", "Heat up Soup"); testRecipe.Save(); Tag firstTag = new Tag("Hearty"); firstTag.Save(); Tag secondTag = new Tag("Soupy"); secondTag.Save(); //Act testRecipe.AddTag(firstTag); testRecipe.AddTag(secondTag); List <Tag> result = testRecipe.GetTags(); List <Tag> testList = new List <Tag> { firstTag, secondTag }; //Assert Assert.Equal(testList, result); }
public void Tag_AddTagsToOneRecipe_True() { //arrange = manual data // add one recipe and two tags Recipe newRecipe = new Recipe("soup", "heat up"); newRecipe.Save(); Tag firstTag = new Tag("first"); Tag secondTag = new Tag("second"); firstTag.Save(); secondTag.Save(); //Act newRecipe.AddTag(firstTag); newRecipe.AddTag(secondTag); List <Tag> result = newRecipe.GetTags(); List <Tag> expected = new List <Tag> { firstTag, secondTag }; Assert.Equal(result, expected); }
public void Test_GetRecipes_ReturnsAllCategoryRecipes() { //Arrange Category testCategory = new Category("Mexican"); testCategory.Save(); Recipe testRecipe1 = new Recipe("Mac and cheese", "cheese and noodles", "cook it", 5); testRecipe1.Save(); Recipe testRecipe2 = new Recipe("Chicken noodle soup", "chicken and water", "cook it", 3); testRecipe2.Save(); //Act testCategory.AddRecipe(testRecipe1); List <Recipe> result = testCategory.GetRecipes(); List <Recipe> testList = new List <Recipe> { testRecipe1 }; //Assert Assert.Equal(testList, result); }
public void Test_Update_UpdateRecipe() { string url = "www.epicodus.com"; string name = "Spaghetti"; Recipe testRecipe1 = new Recipe(name, "Noodles, Sauce", "Boil noodles", "20 Minutes", 5, url); testRecipe1.Save(); string newName = "Chicken Tandoori"; string newIngredients = "Chicken,Onions,Tomato"; string newInstructions = "Roast Chicken"; string newCookTime = "30 minutes"; int newRating = 5; string newUrl = "www.google.com"; testRecipe1.Update(newName, newIngredients, newInstructions, newCookTime, newRating, newUrl); Recipe actualResult = Recipe.GetAll()[0]; Assert.Equal(newName, actualResult.GetName()); Assert.Equal(newIngredients, actualResult.GetIngredients()); Assert.Equal(newInstructions, actualResult.GetInstructions()); Assert.Equal(newCookTime, actualResult.GetTime()); Assert.Equal(newRating, actualResult.GetRating()); Assert.Equal(newUrl, actualResult.GetUrl()); }
public void AddRecipe_AddRecipesToOneTag_True() { //Arrange Tag testTag = new Tag("Funky"); testTag.Save(); Recipe firstRecipe = new Recipe("Soup", "Heat up soup."); firstRecipe.Save(); Recipe secondRecipe = new Recipe("Pizza", "Eat that pizza."); secondRecipe.Save(); //Act testTag.AddRecipe(firstRecipe); testTag.AddRecipe(secondRecipe); List <Recipe> result = testTag.GetRecipes(); List <Recipe> testList = new List <Recipe> { firstRecipe, secondRecipe }; //Assert Assert.Equal(testList, result); }
public void Test_GetCategory_ReturnsAllRecipeCategories() { //Arrange Recipe testRecipe = new Recipe("Spicy Yaki Soba", "Spicy, Soba", "Pour Spicy into Soba"); testRecipe.Save(); Category testCategory1 = new Category("Asian"); testCategory1.Save(); Category testCategory2 = new Category("Mexican"); testCategory2.Save(); //Act testRecipe.AddCategory(testCategory1); List <Category> result = testRecipe.GetCategories(); List <Category> testList = new List <Category> { testCategory1 }; //Assert Assert.Equal(testList, result); }
public void Test_AddCategory_AddCategoryToRecipe() { string url = "www.epicodus.com"; Recipe testRecipe = new Recipe("Chicken Tandoori", "Chicken,Onions,Tomato", "Roast Chicken", "30 minutes", 5, url); testRecipe.Save(); Category testCategory = new Category("Mexican"); testCategory.Save(); Category testCategory2 = new Category("Italian"); testCategory2.Save(); testRecipe.AddCategory(testCategory); testRecipe.AddCategory(testCategory2); List <Category> testList = new List <Category> { testCategory, testCategory2 }; List <Category> result = testRecipe.GetCategories(); Assert.Equal(result, testList); }
public void Recipe_Save_SavesRecipeToDb() { Recipe newRecipe = new Recipe("soup", "heat up"); newRecipe.Save(); Recipe savedRecipe = Recipe.GetAll()[0]; Assert.Equal(newRecipe, savedRecipe); }
public void EditRecipe_EditsRecipeElements_true() { Recipe newRecipe = new Recipe("Chicken Soup", "Lina", "Soup"); newRecipe.Save(); newRecipe.EditRecipe("Tomato Soup", "Brian", "Soup"); Recipe foundRecipe = Recipe.Find(newRecipe.Id); Assert.Equal("Tomato Soup", foundRecipe.Name); }
public void Test_FindRecipe_ReturnsSameObject() { string url = "www.epicodus.com"; Recipe newRecipe = new Recipe("Chicken Tandoori", "Chicken,Onions,Tomato", "Roast Chicken", "30 minutes", 5, url); newRecipe.Save(); Recipe testRecipe = Recipe.Find(newRecipe.GetId()); Assert.Equal(testRecipe, newRecipe); }
public void Save_RecipeIsSavedToDatabase_True() { //Arrange Recipe newRecipe = new Recipe("Soup", "Heat up Soup"); //Act newRecipe.Save(); Recipe savedRecipe = Recipe.GetAll()[0]; //Assert Assert.Equal(newRecipe, savedRecipe); }
public void Save_SaveToDatabase_SaveWithId() { Recipe testRecipe = new Recipe("Chicken Soup", "<Chicken> <Chicken Broth", "Boil broth, cook chicken, put chicken in broth", 4, "30 mins"); testRecipe.Save(); Recipe savedRecipe = Recipe.GetAll()[0]; int output = savedRecipe.GetId(); int expected = testRecipe.GetId(); Assert.Equal(expected, output); }
public void SearchIngredient_ListOfRecipesSearched_ListOfRecipesWithTheIngredient() { Recipe recipe1 = new Recipe("Spaghetti", "<Salt> <Pasta> <Marinara Sauce>", "Boil water, cook pasta, strain pasta, add sauce", 5, "30 mins"); Recipe recipe2 = new Recipe("Chicken Soup", "<Chicken> <Chicken Broth>", "Boil broth, cook chicken, put chicken in broth", 4, "30 mins"); recipe1.Save(); recipe2.Save(); List <Recipe> result = Recipe.SearchIngredient("Pasta"); List <Recipe> expected = new List <Recipe> { recipe1 }; }
public void Test_Find_FindRecipeInDatabase() { //Arrange Recipe testRecipe = new Recipe("Spicy Yaki Soba", "Spicy, Soba", "Pour Spicy into Soba"); testRecipe.Save(); //Act Recipe foundRecipe = Recipe.Find(testRecipe.GetId()); //Assert Assert.Equal(testRecipe, foundRecipe); }
public void Test_Find_FindRecipeInDatabase() { //Arrange Recipe testRecipe = new Recipe("Mac and cheese", "cheese and noodles", "cook it", 5); testRecipe.Save(); //Act Recipe foundRecipe = Recipe.Find(testRecipe.GetId()); //Assert Assert.Equal(testRecipe, foundRecipe); }
public void Test_Save_AssignsIdToObject() { string url = "www.epicodus.com"; Recipe testRecipe = new Recipe("Spaghetti", "Noodles, Sauce", "Boil noodles", "20 Minutes", 5, url); testRecipe.Save(); Recipe savedRecipe = Recipe.GetAll()[0]; int result = savedRecipe.GetId(); int testId = testRecipe.GetId(); Assert.Equal(testId, result); }
public void Save_SaveToDatabase_Save() { Recipe testRecipe = new Recipe("Chicken Soup", "<Chicken, <Chicken Broth", "Boil broth, cook chicken, put chicken in broth", 4, "30 mins"); testRecipe.Save(); List <Recipe> result = Recipe.GetAll(); List <Recipe> verify = new List <Recipe> { testRecipe }; Assert.Equal(verify, result); }
public void Save_SavesRecipeToDB_true() { //Arrange Recipe newRecipe = new Recipe("Chicken Soup", "Lina", "Soup"); Recipe expectedRecipe = new Recipe("Chicken Soup", "Lina", "Soup"); //Act newRecipe.Save(); List <Recipe> allRecipe = Recipe.GetAll(); newRecipe = allRecipe[0]; //Assert Assert.Equal(expectedRecipe, newRecipe); }
public void Test_Save_SavesToDatabase() { //Arrange Recipe testRecipe = new Recipe("Spicy Yaki Soba", "Spicy, Soba", "Pour Spicy into Soba"); //Act testRecipe.Save(); List <Recipe> result = Recipe.GetAll(); List <Recipe> testList = new List <Recipe> { testRecipe }; //Assert Assert.Equal(testList, result); }
public void SortByRate_ListOfRecipes_SortedDesc() { Recipe recipe1 = new Recipe("Spaghetti", "<Pasta, <Marinara Sauce", "Boil water, cook pasta, strain pasta, add sauce", 5, "30 mins"); Recipe recipe2 = new Recipe("Spaghetti", "<Pasta, <Marinara Sauce", "Boil water, cook pasta, strain pasta, add sauce", 4, "30 mins"); recipe1.Save(); recipe2.Save(); List <Recipe> result = Recipe.GetAll(); List <Recipe> expected = new List <Recipe> { recipe1, recipe2 }; Assert.Equal(expected, result); }
public void Test_Save_SavesToDatabase() { //Arrange Recipe testRecipe = new Recipe("Mac and cheese", "cheese and noodles", "cook it", 5); //Act testRecipe.Save(); List <Recipe> result = Recipe.GetAll(); List <Recipe> testList = new List <Recipe> { testRecipe }; //Assert Assert.Equal(testList, result); }
public void Test_DeleteRecipe_DeleteRecipeFromDatabase() { //Arrange Recipe testRecipe = new Recipe("Spaghetti", "<Pasta, <Marinara Sauce", "Boil water, cook pasta, strain pasta, add sauce", 5, "30 mins"); //Act testRecipe.Save(); testRecipe.Delete(); //Assert List <Recipe> expectedResult = new List <Recipe> { }; List <Recipe> actualResult = Recipe.GetAll(); Assert.Equal(expectedResult, actualResult); }
public void Test_Save_AssignsIdToObject() { //Arrange Recipe testRecipe = new Recipe("Mac and cheese", "cheese and noodles", "cook it", 5); //Act testRecipe.Save(); Recipe savedRecipe = Recipe.GetAll()[0]; int result = savedRecipe.GetId(); int testId = testRecipe.GetId(); //Assert Assert.Equal(testId, result); }
public void Test_Save_AssignsIdToObject() { //Arrange Recipe testRecipe = new Recipe("Spicy Yaki Soba", "Spicy, Soba", "Pour Spicy into Soba"); //Act testRecipe.Save(); Recipe savedRecipe = Recipe.GetAll()[0]; int result = savedRecipe.GetId(); int testId = testRecipe.GetId(); //Assert Assert.Equal(testId, result); }
public void Update_UpdatesRecipeNameInDb_True() { string name = "soup"; string instructions = "heat up"; Recipe testRecipe = new Recipe(name, instructions); testRecipe.Save(); string newName = "burgers"; string newInstructions = "fry"; testRecipe.Update(newName, newInstructions); string resultName = testRecipe.GetName(); Assert.Equal(resultName, "burgers"); }
public void Test_DeleteRecipe_DeleteRecipeFromJoinTable() { //Arrange Recipe testRecipe = new Recipe("Spaghetti", "<Pasta, <Marinara Sauce", "Boil water, cook pasta, strain pasta, add sauce", 5, "30 mins"); //Act testRecipe.Save(); testRecipe.Delete(); //Assert List <Recipe> expectedResult = new List <Recipe> { }; List <Recipe> allrecipes = new List <Recipe> { }; SqlConnection conn = DB.Connection(); conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM recipes_tags WHERE recipe_id = 5;", conn); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { int id = rdr.GetInt32(0); string name = rdr.GetString(1); string ingredients = rdr.GetString(2); string instructions = rdr.GetString(3); int rate = rdr.GetInt32(4); string time = rdr.GetString(5); Recipe newRecipe = new Recipe(name, ingredients, instructions, rate, time, id); allrecipes.Add(newRecipe); } if (rdr != null) { rdr.Close(); } if (conn != null) { conn.Close(); } Assert.Equal(expectedResult, allrecipes); }
public void Test_Update_UpdateRecipeInDatabase() { Recipe testRecipe = new Recipe("Spaghetti", "<Pasta, <Marinara Sauce", "Boil water, cook pasta, strain pasta, add sauce", 5, "30 mins"); testRecipe.Save(); string newRecipeName = "Chicken Soup"; string newIngredients = "<Chicken, <Chicken Broth"; string newInstructions = "Boil broth, cook chicken, add chicken to broth"; int newRate = 4; string newTime = "30 mins"; testRecipe.Update(newRecipeName, newIngredients, newInstructions, newRate, newTime); Recipe actualResult = testRecipe; Recipe expectedResult = new Recipe(newRecipeName, newIngredients, newInstructions, newRate, newTime, testRecipe.GetId()); Assert.Equal(expectedResult, actualResult); }
public void SaveInstructions_SavesInstructionsToDB() { //Arrange Recipe newRecipe = new Recipe("Chicken Soup", "Lina", "Soup"); List <string> instructions = new List <string>() { "Put Chicken In", "Cook" }; newRecipe.Save(); newRecipe.SetInstructions(instructions); newRecipe.SaveInstructions(); //Act List <string> actualInstructions = newRecipe.GetInstructionsFromDB(); //Assert Assert.Equal(2, actualInstructions.Count); }
public void Find_FindsRecipeInRecipes_true() { //Arrange Recipe newRecipe = new Recipe("Chicken Soup", "Lina", "Soup"); newRecipe.Save(); Dictionary <string, string> ingredients = new Dictionary <string, string>() { { "chicken", "1lb" }, { "rice", "1lb" }, { "carrots", "1/2c" }, { "peas", "1/4c" }, { "onions", "1/4c" } }; newRecipe.SetIngredients(ingredients); newRecipe.SaveIngredients(); //Act Recipe findRecipe = Recipe.Find(newRecipe.GetId()); //Assert Assert.Equal(newRecipe, findRecipe); }