public async Task DisplayWhenPostThrowsIfSaveSurveyAnswersReadFromSurveyStoreHaveDifferentCountToTheSurveyAnswerParameter() { var surveyWith1Question = new ClientModels.Survey() { Questions = new List <ClientModels.Question>() { new ClientModels.Question() } }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(surveyWith1Question); var surveyAnswerWithoutQuestions = new SurveyAnswer(); using (var controller = new SurveysController( mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object, new Mock <ISurveyResponseService>().Object)) { await AssertEx.ThrowsExceptionAsync <ArgumentException>( async() => await controller.Display(string.Empty, surveyAnswerWithoutQuestions), string.Empty, null); } }
public void DisplayCopiesTheSurveyQuestionTextToTheSurveyAnswerReturnedInTheContentModel() { var survey = new Survey { Questions = new List <Question>( new[] { new Question { Text = "question text to copy" }, }) }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { var result = controller.Display("tenant", string.Empty) as ViewResult; var model = result.ViewData.Model as TenantPageViewData <SurveyAnswer>; Assert.AreEqual("question text to copy", model.ContentModel.QuestionAnswers.First().QuestionText); } }
public void DisplayTransformsAllTheSurveyQuestionsToQuestionAnswerRetrnedInTheContentModel() { var survey = new Survey { Questions = new List <Question>( new[] { new Question(), new Question() }) }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { var result = controller.Display("tenant", string.Empty) as ViewResult; var model = result.ViewData.Model as TenantPageViewData <SurveyAnswer>; Assert.AreEqual(2, model.ContentModel.QuestionAnswers.Count()); } }
public async Task DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithTheSlugParameterWhenModelIsValid() { var survey = new ClientModels.Survey() { SlugName = "slug" }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); var mockSurveyAnswerService = new Mock <ISurveyAnswerService>(); var mockSurveyResponseService = new Mock <ISurveyResponseService>(); using (var controller = new SurveysController( mockSurveyManagementService.Object, mockSurveyAnswerService.Object, mockSurveyResponseService.Object)) { await controller.Display("slug", new SurveyAnswer()); } mockSurveyResponseService.Verify(r => r.SaveSurveyResponseAsync( It.Is <ClientModels.SurveyAnswer>( sa => "slug" == sa.SlugName)), Times.Once); }
public void DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithAnswerReadFromTheParameterWhenModelIsValid() { var survey = new Survey { Questions = new List <Question>(new[] { new Question() }) }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); var surveyAnswer = new SurveyAnswer { QuestionAnswers = new List <QuestionAnswer>(new[] { new QuestionAnswer { Answer = "answer" } }) }; using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { controller.Display(string.Empty, string.Empty, surveyAnswer); } mockSurveyAnswerStore.Verify( r => r.SaveSurveyAnswer( It.Is <SurveyAnswer>(sa => "answer" == sa.QuestionAnswers[0].Answer)), Times.Once()); }
public async Task DisplayCopiesTheSurveyQuestionTypeToTheQuestionAnswerReturnedInTheContentModel() { var survey = new Survey { Questions = new List <Question>( new[] { new Question { Type = QuestionType.SimpleText }, }) }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .ReturnsAsync(survey); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { var result = await controller.Display("tenant", string.Empty) as ViewResult; var model = result.ViewData.Model as TenantPageViewData <SurveyAnswer>; Assert.AreEqual(QuestionType.SimpleText, model.ContentModel.QuestionAnswers.First().QuestionType); } }
public async Task DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithQuestionTypeReadFromTheSurveyWhenModelIsValid() { var survey = new Survey { Questions = new List <Question>( new[] { new Question { Type = QuestionType.SimpleText }, }) }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .ReturnsAsync(survey); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); var surveyAnswer = new SurveyAnswer { QuestionAnswers = new List <QuestionAnswer>(new[] { new QuestionAnswer() }) }; using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { await controller.Display(string.Empty, string.Empty, surveyAnswer); } mockSurveyAnswerStore.Verify( r => r.SaveSurveyAnswerAsync( It.Is <SurveyAnswer>(sa => QuestionType.SimpleText == sa.QuestionAnswers[0].QuestionType)), Times.Once()); }
public void DisplayWhenPostReturnsModelWithTheAnswersReadFromTheParameterWhenModelIsNotValid() { var mockSurveyStore = new Mock <ISurveyStore>(); var survey = new Survey { Questions = new List <Question>(new[] { new Question() }) }; mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); var surveyAnswer = new SurveyAnswer { QuestionAnswers = new List <QuestionAnswer>(new[] { new QuestionAnswer { Answer = "answer" } }) }; using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { controller.ModelState.AddModelError("error for test", "invalid model state"); var result = controller.Display(string.Empty, string.Empty, surveyAnswer) as ViewResult; var model = result.ViewData.Model as TenantPageViewData <SurveyAnswer>; Assert.AreEqual("answer", model.ContentModel.QuestionAnswers.First().Answer); } }
public async Task DisplayWhenPostReturnsSurveyTitleAsTitleInTheModelWhenModelIsNotValid() { var mockSurveyManagementService = new Mock <ISurveyManagementService>(); var survey = new Tailspin.SurveyManagementService.Client.Models.Survey() { Title = "title", Questions = new List <Tailspin.SurveyManagementService.Client.Models.Question>() { new Tailspin.SurveyManagementService.Client.Models.Question() } }; mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); var surveyAnswer = new SurveyAnswer() { QuestionAnswers = new List <QuestionAnswer>() { new QuestionAnswer() } }; using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { controller.ModelState.AddModelError("error for test", "invalid model state"); var result = await controller.Display(string.Empty, surveyAnswer) as ViewResult; var model = result.ViewData.Model as MasterPageViewData; Assert.AreSame("title", model.Title); } }
public void DisplayWhenPostReturnsSurveyTitleAsTitleInTheModelWhenModelIsNotValid() { var mockSurveyStore = new Mock <ISurveyStore>(); var survey = new Survey { Title = "title", Questions = new List <Question>(new[] { new Question() }) }; mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); var surveyAnswer = new SurveyAnswer { QuestionAnswers = new List <QuestionAnswer>(new[] { new QuestionAnswer() }) }; using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { controller.ModelState.AddModelError("error for test", "invalid model state"); var result = controller.Display(string.Empty, string.Empty, surveyAnswer) as ViewResult; var model = result.ViewData.Model as TenantMasterPageViewData; Assert.AreSame("title", model.Title); } }
public async Task DisplayWhenPostReturnsModelWithTheAnswersReadFromTheParameterWhenModelIsNotValid() { var mockSurveyManagementService = new Mock <ISurveyManagementService>(); var survey = new Tailspin.SurveyManagementService.Client.Models.Survey() { Questions = new List <Tailspin.SurveyManagementService.Client.Models.Question>() { new Tailspin.SurveyManagementService.Client.Models.Question() } }; mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); var surveyAnswer = new SurveyAnswer { QuestionAnswers = new List <QuestionAnswer>() { new QuestionAnswer { Answer = "answer" } } }; using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { controller.ModelState.AddModelError("error for test", "invalid model state"); var result = await controller.Display(string.Empty, surveyAnswer) as ViewResult; var model = result.ViewData.Model as PageViewData <SurveyAnswer>; Assert.AreEqual("answer", model.ContentModel.QuestionAnswers.First().Answer); } }
public async Task DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithAnswerReadFromTheParameterWhenModelIsValid() { var survey = new Tailspin.SurveyManagementService.Client.Models.Survey() { Questions = new List <Tailspin.SurveyManagementService.Client.Models.Question>() { new Tailspin.SurveyManagementService.Client.Models.Question() } }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); var mockSurveyAnswerService = new Mock <ISurveyAnswerService>(); var surveyAnswer = new SurveyAnswer() { QuestionAnswers = new List <QuestionAnswer>() { new QuestionAnswer() { Answer = "answer" } } }; using (var controller = new SurveysController(mockSurveyManagementService.Object, mockSurveyAnswerService.Object)) { await controller.Display(string.Empty, surveyAnswer); } mockSurveyAnswerService.Verify(r => r.SaveSurveyAnswerAsync( It.Is <Tailspin.SurveyAnswerService.Client.Models.SurveyAnswer>(sa => "answer" == sa.QuestionAnswers[0].Answer)), Times.Once); }
public async Task DisplayCopiesTheSurveyQuestionTextToTheSurveyAnswerReturnedInTheContentModel() { var survey = new ClientModels.Survey() { Questions = new List <ClientModels.Question>() { new ClientModels.Question() { Text = "question text to copy" } } }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); using (var controller = new SurveysController( mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object, new Mock <ISurveyResponseService>().Object)) { var result = await controller.Display(string.Empty) as ViewResult; var model = result.ViewData.Model as PageViewData <SurveyAnswer>; Assert.AreEqual("question text to copy", model.ContentModel.QuestionAnswers.First().QuestionText); } }
public async Task DisplayWhenPostReturnsEmptyViewNameWhenModelIsNotValid() { var mockSurveyManagementService = new Mock <ISurveyManagementService>(); var survey = new ClientModels.Survey() { Questions = new List <ClientModels.Question>() { new ClientModels.Question() } }; mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); var surveyAnswer = new SurveyAnswer() { QuestionAnswers = new List <QuestionAnswer>() { new QuestionAnswer() } }; using (var controller = new SurveysController( mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object, new Mock <ISurveyResponseService>().Object)) { controller.ModelState.AddModelError("error for test", "invalid model state"); var result = await controller.Display(string.Empty, surveyAnswer) as ViewResult; Assert.IsNull(result.ViewName); } }
public void DisplayReturnsEmptyViewName() { var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(new Survey()); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { var result = controller.Display("tenant", string.Empty) as ViewResult; Assert.AreEqual(string.Empty, result.ViewName); } }
public async Task DisplayReturnsEmptyViewName() { var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(new Tailspin.SurveyManagementService.Client.Models.Survey()); using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { var result = await controller.Display(string.Empty) as ViewResult; Assert.IsNull(result.ViewName); } }
public async Task DisplayWhenPostReturnsRedirectToThankYouAction() { var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(new Tailspin.SurveyManagementService.Client.Models.Survey()); using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { var result = await controller.Display(string.Empty, new SurveyAnswer()) as RedirectToActionResult; Assert.AreEqual("ThankYou", result.ActionName); Assert.AreEqual(null, result.ControllerName); } }
public void DisplayWhenPostReturnsRedirectToThankYouAction() { var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(new Survey()); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { var result = controller.Display("tenant", string.Empty, new SurveyAnswer()) as RedirectToRouteResult; Assert.AreEqual("ThankYou", result.RouteValues["action"]); Assert.AreEqual(null, result.RouteValues["controller"]); } }
public async Task DisplayWhenPostReturnsRedirectToThankYouAction() { var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .ReturnsAsync(new Survey()); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { var result = await controller.Display("tenant", string.Empty, new SurveyAnswer()) as RedirectToActionResult; Assert.AreEqual("ThankYou", result.ActionName); Assert.AreEqual(null, result.ControllerName); } }
public async Task DisplayCallsStoreWithSlugForSurveyToGet() { var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(new Tailspin.SurveyManagementService.Client.Models.Survey()); using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { await controller.Display("slug"); } mockSurveyManagementService.Verify( r => r.GetSurveyAsync( It.Is <string>(s => "slug" == s)), Times.Once()); }
public void DisplayWhenPostThrowsIfSaveSurveyAnswersReadFromSurveyStoreHaveDifferentCountToTheSurveyAnswerParameter() { var surveyWith1Question = new Survey { Questions = new List <Question>(new[] { new Question() }) }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(surveyWith1Question); var surveyAnswerWithoutQuestions = new SurveyAnswer(); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { controller.Display(string.Empty, string.Empty, surveyAnswerWithoutQuestions); } }
public void DisplayCopiesTheSurveyTitleToTheSurveyAnswerReturnedInTheContentModel() { var survey = new Survey { Title = "title to be copied" }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { var result = controller.Display("tenant", string.Empty) as ViewResult; var model = result.ViewData.Model as TenantPageViewData <SurveyAnswer>; Assert.AreEqual("title to be copied", model.ContentModel.Title); } }
public void DisplayCallsStoreWithTenantAndIdForSurveyToGet() { var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(new Survey()); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { controller.Display("tenant", "slug"); } mockSurveyStore.Verify( r => r.GetSurveyByTenantAndSlugName( It.Is <string>(t => "tenant" == t), It.Is <string>(s => "slug" == s), It.Is <bool>(b => b)), Times.Once()); }
public void DisplayReturnsSurveyTitleAsTitleInTheModel() { var survey = new Survey { Title = "title" }; var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore))) { var result = controller.Display("tenant", string.Empty) as ViewResult; var model = result.ViewData.Model as TenantMasterPageViewData; Assert.AreSame("title", model.Title); } }
public async Task DisplayReturnsSurveyTitleAsTitleInTheModel() { var survey = new Tailspin.SurveyManagementService.Client.Models.Survey { Title = "title" }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { var result = await controller.Display(string.Empty) as ViewResult; var model = result.ViewData.Model as MasterPageViewData; Assert.AreSame("title", model.Title); } }
public async Task DisplayCopiesTheSurveyTitleToTheSurveyAnswerReturnedInTheContentModel() { var survey = new Tailspin.SurveyManagementService.Client.Models.Survey() { Title = "title to be copied" }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object)) { var result = await controller.Display(string.Empty) as ViewResult; var model = result.ViewData.Model as PageViewData <SurveyAnswer>; Assert.AreEqual("title to be copied", model.ContentModel.Title); } }
public async Task DisplayWhenPostCallsStoreWithTenantAndIdForSurveyToGet() { var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .ReturnsAsync(new Survey()); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { await controller.Display("tenant", "slug", new SurveyAnswer()); } mockSurveyStore.Verify( r => r.GetSurveyByTenantAndSlugNameAsync( It.Is <string>(t => "tenant" == t), It.Is <string>(s => "slug" == s), It.Is <bool>(b => b)), Times.Once()); }
public async Task DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithTheTenantReadFromTheControllerWhenModelIsValid() { var survey = new Survey(); var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .ReturnsAsync(survey); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { await controller.Display("tenant", string.Empty, new SurveyAnswer()); } mockSurveyAnswerStore.Verify( r => r.SaveSurveyAnswerAsync( It.Is <SurveyAnswer>(sa => "tenant" == sa.TenantId)), Times.Once()); }
public void DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithTheSlugParameterWhenModelIsValid() { var survey = new Survey(); var mockSurveyStore = new Mock <ISurveyStore>(); mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(survey); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); using (var controller = new SurveysController(mockSurveyStore.Object, mockSurveyAnswerStore.Object)) { controller.Display(string.Empty, "slug", new SurveyAnswer()); } mockSurveyAnswerStore.Verify( r => r.SaveSurveyAnswer( It.Is <SurveyAnswer>(sa => "slug" == sa.SlugName)), Times.Once()); }
public async Task DisplayWhenPostCallsSaveSurveyAnswerFromSurveyAnswerStoreWithQuestionTypeReadFromTheSurveyWhenModelIsValid() { var survey = new ClientModels.Survey { Questions = new List <ClientModels.Question> { new ClientModels.Question { Type = ClientModels.QuestionType.SimpleText }, } }; var mockSurveyManagementService = new Mock <ISurveyManagementService>(); mockSurveyManagementService.Setup(r => r.GetSurveyAsync(It.IsAny <string>())) .ReturnsAsync(survey); var mockSurveyAnswerService = new Mock <ISurveyAnswerService>(); var mockSurveyResponseService = new Mock <ISurveyResponseService>(); var surveyAnswer = new SurveyAnswer() { QuestionAnswers = new List <QuestionAnswer>() { new QuestionAnswer() } }; using (var controller = new SurveysController( mockSurveyManagementService.Object, mockSurveyAnswerService.Object, mockSurveyResponseService.Object)) { await controller.Display(string.Empty, surveyAnswer); } mockSurveyResponseService.Verify(r => r.SaveSurveyResponseAsync( It.Is <ClientModels.SurveyAnswer>( sa => ClientModels.QuestionType.SimpleText == sa.QuestionAnswers[0].QuestionType)), Times.Once); }