public async Task BrowseResponsesSetsTheAnswerFromTheStoreInTheModel()
        {
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();
            var surveyAnswer          = new SurveyAnswer();

            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContextAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new SurveyAnswerBrowsingContext {
                PreviousId = string.Empty, NextId = string.Empty
            });
            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerAsync("tenant", "survey-slug", "answer id"))
            .ReturnsAsync(surveyAnswer);

            var mockTenantStore = new Mock <ITenantStore>();

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

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, mockTenantStore.Object, null))
            {
                var result = await controller.BrowseResponses("tenant", "survey-slug", "answer id") as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData <BrowseResponseModel>;
                Assert.AreSame(surveyAnswer, model.ContentModel.SurveyAnswer);
            }
        }
Exemple #2
0
        public void BrowseResponsesGetsTheFirstAnswerIdFromTheStoreWhenAnswerIdIsEmpty()
        {
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();

            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContext(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new SurveyAnswerBrowsingContext {
                PreviousId = string.Empty, NextId = string.Empty
            });

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, null, null))
            {
                controller.BrowseResponses("tenant", "survey-slug", string.Empty);
            }

            mockSurveyAnswerStore.Verify(r => r.GetFirstSurveyAnswerId("tenant", "survey-slug"), Times.Once());
        }
Exemple #3
0
        public void BrowseResponsesReturnSlugNameAsTheTitle()
        {
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();

            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContext(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new SurveyAnswerBrowsingContext {
                PreviousId = string.Empty, NextId = string.Empty
            });

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, null, null))
            {
                var result = controller.BrowseResponses(string.Empty, "slug-name", string.Empty) as ViewResult;

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreSame("slug-name", model.Title);
            }
        }
Exemple #4
0
        public void BrowseResponsesSetsPreviousAndNextIdsInModel()
        {
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();

            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContext(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new SurveyAnswerBrowsingContext {
                PreviousId = "PreviousId", NextId = "NextId"
            });

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, null, null))
            {
                var result = controller.BrowseResponses("tenant", "survey-slug", "answer id") as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData <BrowseResponseModel>;
                Assert.AreEqual("PreviousId", model.ContentModel.PreviousAnswerId);
                Assert.AreEqual("NextId", model.ContentModel.NextAnswerId);
            }
        }
        public async Task BrowseResponsesGetsTheAnswerFromTheStoreWhenAnswerIdIsNotEmpty()
        {
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();

            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContextAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new SurveyAnswerBrowsingContext {
                PreviousId = string.Empty, NextId = string.Empty
            });

            var mockTenantStore = new Mock <ITenantStore>();

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

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, mockTenantStore.Object, null))
            {
                await controller.BrowseResponses("tenant", "survey-slug", "answer id");
            }

            mockSurveyAnswerStore.Verify(r => r.GetSurveyAnswerAsync("tenant", "survey-slug", "answer id"));
        }