コード例 #1
0
        public void StepOnePostAction_ReturnsRedirectToAction()
        {
            var mockDataAccessor = new Mock <IVacationPlannerDataAccessor>();
            var httpContext      = new DefaultHttpContext();
            var tempData         = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());
            var httpCtx          = new Mock <IHttpContextAccessor>();

            mockDataAccessor.Setup(m => m.Locations).Returns(new Mock <IRepository <Location> >().Object);
            mockDataAccessor.Setup(m => m.Accommodations).Returns(new Mock <IRepository <Accommodation> >().Object);
            mockDataAccessor.Setup(m => m.Activities).Returns(new Mock <IRepository <Activity> >().Object);
            mockDataAccessor.Setup(m => m.Vacations).Returns(new Mock <IRepository <Vacation> >().Object);

            var controller = new VacationController(mockDataAccessor.Object, httpCtx.Object)
            {
                TempData = tempData
            };
            var result = controller.StepOne(new VacationStepOneViewModel()
            {
                Vacation = new Vacation()
                {
                    Location = new Location()
                },
                Locations      = new List <Location>(),
                Accommodations = new List <Accommodation>()
            });

            Assert.IsType <RedirectToActionResult>(result);
        }