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");
        }
示例#2
0
 public ActionResult Edit(int id, RecipeDetailsModel updated)
 {
     ro.UpdateRecipe(id, updated);
     return RedirectToAction("FullDetails", new { id = id });
 }
        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");
        }
示例#4
0
 public ActionResult Submit(RecipeDetailsModel r)
 {
     var id = ro.AddRecipe(r);
     return RedirectToAction("FullDetails", new { id = id });
 }