public ActionResult Create(string recipeName, string recipeRating, string categoryName) { Recipe newRecipe = new Recipe(recipeName, int.Parse(recipeRating)); newRecipe.Save(); RecipeCategory newPair = new RecipeCategory(newRecipe.GetId(), Category.FindCategoryByName(categoryName).GetId()); newPair.Save(); return(RedirectToAction("Index")); }
public void Find_FindRecipeCategoryInDatabase_RecipeCategory() { //Arrange RecipeCategory testRecipeCategory = new RecipeCategory(1, 1); testRecipeCategory.Save(); //Act RecipeCategory resultById = RecipeCategory.FindRecipeCategoryById(testRecipeCategory.GetId()); //Assert Assert.AreEqual(testRecipeCategory, resultById); }
public void SaveAndGetAll_SavesToDatabaseAndReturnAll_RecipeCategory() { //Arrange RecipeCategory testRecipeCategory = new RecipeCategory(1, 1); //Act testRecipeCategory.Save(); List <RecipeCategory> result = RecipeCategory.GetAll(); List <RecipeCategory> testList = new List <RecipeCategory> { testRecipeCategory }; //Assert CollectionAssert.AreEqual(testList, result); }
public void Save_AssignsIdToObject_Id() { //Arrange RecipeCategory testRecipeCategory = new RecipeCategory(1, 1); //Act testRecipeCategory.Save(); RecipeCategory savedRecipeCategory = RecipeCategory.GetAll()[0]; int result = savedRecipeCategory.GetId(); int testId = testRecipeCategory.GetId(); //Assert Assert.AreEqual(testId, result); }