Beispiel #1
0
        public void NewQuestionReturnsEmptyViewName()
        {
            using (var controller = new SurveysController(null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = new SurveyModel();

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

                Assert.AreEqual(string.Empty, result.ViewName);
            }
        }
        public async Task NewQuestionRedirectToTheNewActionWhenCachedSurveyIsNull()
        {
            using (var controller = new SurveysController(new Mock <ISurveyStore>().Object, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = null;

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

                Assert.AreEqual("New", result.RouteValues["action"]);
                Assert.AreEqual(null, result.RouteValues["controller"]);
            }
        }
Beispiel #3
0
        public void NewQuestionReturnsNewQuestionInTheModel()
        {
            using (var controller = new SurveysController(null, null, null, null, null))
            {
                controller.TempData[SurveysController.CachedSurvey] = new SurveyModel();

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

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

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

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreSame("New Question", model.Title);
            }
        }
        public async Task NewQuestionReturnsEmptyViewName()
        {
            var mockTenantStore = new Mock <ITenantStore>();

            mockTenantStore.Setup(r => r.GetTenantAsync(It.IsAny <string>()))
            .ReturnsAsync(new Tenant());

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

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

                Assert.AreEqual(string.Empty, result.ViewName);
            }
        }
Beispiel #6
0
        public void NewQuestionCopiesSurveyTitleToCachedSurveyThatIsReturnedInViewData()
        {
            var survey = new SurveyModel {
                Title = "title"
            };

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

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

                var cachedSurvey = result.TempData[SurveysController.CachedSurvey] as SurveyModel;
                Assert.AreSame(survey.Title, cachedSurvey.Title);
            }
        }
        public async Task NewQuestionReturnsNewQuestionInTheModel()
        {
            var mockTenantStore = new Mock <ITenantStore>();

            mockTenantStore.Setup(r => r.GetTenantAsync(It.IsAny <string>()))
            .ReturnsAsync(new Tenant());

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

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

                var model = result.ViewData.Model as TenantPageViewData <Question>;
                Assert.IsInstanceOfType(model.ContentModel, typeof(Question));
            }
        }
        public async Task NewQuestionReturnsNewQuestionAsTitleInTheModel()
        {
            var mockTenantStore = new Mock <ITenantStore>();

            mockTenantStore.Setup(r => r.GetTenantAsync(It.IsAny <string>()))
            .ReturnsAsync(new Tenant());

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

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

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreSame("New Question", model.Title);
            }
        }
        public async Task NewQuestionCopiesSurveyTitleToCachedSurveyThatIsReturnedInViewData()
        {
            var mockTenantStore = new Mock <ITenantStore>();

            mockTenantStore.Setup(r => r.GetTenantAsync(It.IsAny <string>()))
            .ReturnsAsync(new Tenant());

            var survey = new SurveyModel {
                Title = "title"
            };

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

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

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