Esempio n. 1
0
 public void UpdateRecipe(int id, RecipeDetailsModel updated)
 {
     Recipes[id].Name = updated.Name;
     Recipes[id].Summary = updated.Summary;
     Recipes[id].CookingTimeInMinutes = updated.CookingTimeInMinutes;
     Recipes[id].Ingredients = updated.Ingredients;
     Recipes[id].Instructions = updated.Instructions;
 }
        public void PostSubmitAddsRecipeAndRedirectsCorrectly()
        {
            roStub.AddRecipe(null)
                .ReturnsForAnyArgs(42);
            var testModel = new RecipeDetailsModel();

            var result = sut.Submit(testModel) as RedirectToRouteResult;
            Assert.IsNotNull(result, "Result redirects");

            roStub.Received().AddRecipe(testModel);
            Assert.AreEqual(42, (int)result.RouteValues["id"], "Correct ID in redirect");
        }
        public void PostEditUpdatesDetailsAndRedirects()
        {
            var testModel = new RecipeDetailsModel();

            var result = sut.Edit(13, testModel) as RedirectToRouteResult;
            Assert.IsNotNull(result, "Result redirects");

            roStub.Received().UpdateRecipe(13, testModel); 
            Assert.AreEqual(13, (int)result.RouteValues["id"], "Correct ID in redirect");
        }
Esempio n. 4
0
 public ActionResult Edit(int id, RecipeDetailsModel updated)
 {
     ro.UpdateRecipe(id, updated);
     return RedirectToAction("FullDetails", new { id = id });
 }
Esempio n. 5
0
 public ActionResult Submit(RecipeDetailsModel r)
 {
     var id = ro.AddRecipe(r);
     return RedirectToAction("FullDetails", new { id = id });
 }
Esempio n. 6
0
 public int AddRecipe(RecipeDetailsModel r)
 {
     Recipes.Add(r);
     return Recipes.Count - 1;
 }