コード例 #1
0
        public void NewQuestionReturnsNewQuestionInTheModel()
        {
            using (var controller = new SurveysController(null, null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = new Survey();

                var result = controller.NewQuestion(new Survey()) as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData<Question>;
                Assert.IsInstanceOfType(model.ContentModel, typeof(Question));
            }
        }
コード例 #2
0
        public void NewQuestionReturnsNewQuestionAsTitleInTheModel()
        {
            using (var controller = new SurveysController(null, null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = new Survey();

                var result = controller.NewQuestion(new Survey()) as ViewResult;

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreSame("New Question", model.Title);
            }
        }
コード例 #3
0
        public void NewQuestionRedirectToTheNewActionWhenCachedSurveyIsNull()
        {
            using (var controller = new SurveysController(new Mock<ISurveyStore>().Object, null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = null;

                var result = controller.NewQuestion(new Survey()) as RedirectToRouteResult;

                Assert.AreEqual("New", result.RouteValues["action"]);
                Assert.AreEqual(null, result.RouteValues["controller"]);
            }
        }
コード例 #4
0
        public void NewQuestionReturnsEmptyViewName()
        {
            using (var controller = new SurveysController(null, null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = new Survey();

                var result = controller.NewQuestion(new Survey()) as ViewResult;

                Assert.AreEqual(string.Empty, result.ViewName);
            }
        }
コード例 #5
0
        public void NewQuestionCopiesSurveyTitleToCachedSurveyThatIsReturnedInViewData()
        {
            var survey = new Survey { Title = "title" };

            using (var controller = new SurveysController(null, null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = new Survey();

                var result = controller.NewQuestion(survey) as ViewResult;

                var cachedSurvey = result.TempData[SurveysController.CachedSurvey] as Survey;
                Assert.AreSame(survey.Title, cachedSurvey.Title);
            }
        }