public void BrowseResponsesSetsTheAnswerFromTheStoreInTheModel() { var mockSurveyAnswerStore = new Mock<ISurveyAnswerStore>(); var surveyAnswer = new SurveyAnswer(); mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerBrowsingContext(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Returns(new SurveyAnswerBrowsingContext { PreviousId = string.Empty, NextId = string.Empty }); mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswer("tenant", "survey-slug", "answer id")) .Returns(surveyAnswer); using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, null, null, null)) { var result = controller.BrowseResponses("tenant", "survey-slug", "answer id") as ViewResult; var model = result.ViewData.Model as TenantPageViewData<BrowseResponseModel>; Assert.AreSame(surveyAnswer, model.ContentModel.SurveyAnswer); } }
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, 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); } }
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, 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 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, null)) { controller.BrowseResponses("tenant", "survey-slug", string.Empty); } mockSurveyAnswerStore.Verify(r => r.GetFirstSurveyAnswerId("tenant", "survey-slug"), Times.Once()); }