예제 #1
0
        public void BooksByGenrePost_CheckRedirectionAndSession(int id, int quantity, int gId)
        {
            using (var homeController = new HomeController(MockData.MoqLogger(), MockData.MoqShopContext(),
                                                           MockData.MoqEmailSender(), MockData.MoqMyLogger()))
            {
                var formCollection = new FormCollection(new Dictionary <string, StringValues>()
                {
                    { "Genres", gId.ToString() }
                });

                var controllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext
                    {
                        Session = new MockHttpSession(),
                        Request = { Form = formCollection }
                    },
                };

                homeController.ControllerContext = controllerContext;


                var action = homeController.BooksByGenrePost(id, quantity, gId) as RedirectToActionResult;

                Assert.Equal("BooksByGenre", action.ActionName);
                Assert.Equal(gId.ToString(), action.RouteValues["genreId"].ToString());
            }
        }