public ActionResult Submit(GuestBookEntryModel submittedGuestBookEntry, HttpPostedFileBase imageFileUpload)
        {
            if (!ModelState.IsValid)
            {
                //retainUploadedImage(imageFileUpload);
                return RedirectToAction("Index");
            }

            SubmitGuestBookEntryResponse response =
                _guestBookService.SubmitGuestBookEntry(new SubmitGuestBookEntryRequest { Name = submittedGuestBookEntry.Name, Comment = submittedGuestBookEntry.Comment, ImageFile = imageFileUpload });

            if (response.IsSuccess)
            {
                ModelState.Clear();
                TempData["SubmitResponse"] = new SubmitResponse
                    {
                        Message = "Data submission is success.",
                        IsSuccess = true
                    };
            }
            else
            {
                ModelState.AddModelError(string.Empty, response.Errors.ToString());
                TempData["SubmitResponse"] = new SubmitResponse { Message = "Data submission is Failed." };
            }

            return RedirectToAction("Index");
        }
        public void Can_Submit_Guest_Book_Entry()
        {
            // Arrange
            SubmitGuestBookEntryRequest submitGuestBookEntryRequest = new SubmitGuestBookEntryRequest
                {
                    Name = TEST_GUEST_NAME,
                    Comment = TEST_GUEST_COMMENT,
                    ImageFile = null
                };
            SubmitGuestBookEntryResponse expectedSubmitGuestBookEntryResponse = new SubmitGuestBookEntryResponse { IsSuccess = true };

            IGuestBookService guestBookService = _mockRepository.Stub<IGuestBookService>();
            using (_mockRepository.Record())
            {
                SetupResult
                    .For(guestBookService.SubmitGuestBookEntry(submitGuestBookEntryRequest))
                    .IgnoreArguments()
                    .Return(expectedSubmitGuestBookEntryResponse);
            }

            HomeController homeController = new HomeController(guestBookService);
            GuestBookEntryModel guestBookEntryModel = new GuestBookEntryModel { Name = TEST_GUEST_NAME, Comment = TEST_GUEST_COMMENT };

            // Act
            var actionResult = homeController.Submit(guestBookEntryModel, null);
            RedirectToRouteResult redirectToRouteResult = actionResult as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(redirectToRouteResult);
            Assert.IsNotNull(redirectToRouteResult.RouteValues["action"]);
            Assert.AreEqual("Index", redirectToRouteResult.RouteValues["action"]);
            SubmitResponse submitResponse = homeController.TempData["SubmitResponse"] as SubmitResponse;
            Assert.IsNotNull(submitResponse);
            Assert.AreEqual(true, submitResponse.IsSuccess);
            Assert.AreEqual("Data submission is success.", submitResponse.Message);
        }
        private void testSubmitGuestBookEntry(HomeController homeController, HttpPostedFileBase imageUpload)
        {
            // Arrange            
            _guestBookEntryModel = new GuestBookEntryModel { Name = TEST_GUEST_NAME, Comment = TEST_GUEST_COMMENT };

            // Act            
            var submitActionResult = homeController.Submit(_guestBookEntryModel, imageUpload);
            var redirectToRouteResult = submitActionResult as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(redirectToRouteResult);
            Assert.IsNotNull(redirectToRouteResult.RouteValues["action"]);
            Assert.AreEqual("Index", redirectToRouteResult.RouteValues["action"]);
            var submitResponse = homeController.TempData["SubmitResponse"] as SubmitResponse;
            Assert.IsNotNull(submitResponse);
            Assert.AreEqual(true, submitResponse.IsSuccess);
            Assert.AreEqual("Data submission is success.", submitResponse.Message);

        }