public async Task ExportPostRedirectsToBrowseAction()
        {
            var mockSurveyTransferStore = new Mock <ISurveyTransferStore>();

            using (var controller = new SurveysController(null, null, null, null, mockSurveyTransferStore.Object))
            {
                var result = await controller.ExportResponses("tenant", "slugName") as RedirectToRouteResult;

                Assert.AreEqual(result.RouteValues["action"], "BrowseResponses");
            }
        }
        public async Task ExportPostCallsTransferPostWithTenantAndSlugName()
        {
            var mockSurveyTransferStore = new Mock <ISurveyTransferStore>();

            using (var controller = new SurveysController(null, null, null, null, mockSurveyTransferStore.Object))
            {
                await controller.ExportResponses("tenant", "slugName");
            }

            mockSurveyTransferStore.Verify(r => r.TransferAsync("tenant", "slugName"), Times.Once());
        }
        public async Task ExportDeterminesIfThereAreResponsesToExport()
        {
            var mockTenantStore       = new Mock <ITenantStore>();
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();
            var tenant = new Tenant();

            mockTenantStore.Setup(r => r.GetTenantAsync(It.IsAny <string>())).ReturnsAsync(tenant);
            mockSurveyAnswerStore.Setup(r => r.GetFirstSurveyAnswerIdAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(string.Empty);

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, mockTenantStore.Object, null))
            {
                var result = await controller.ExportResponses(string.Empty) as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData <ExportResponseModel>;
                Assert.AreEqual(false, model.ContentModel.HasResponses);
            }
        }
        public async Task ExportGetsTheTenantInformationAndPutsInModel()
        {
            var tenant = new Tenant();

            var mockTenantStore       = new Mock <ITenantStore>();
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();

            mockTenantStore.Setup(r => r.GetTenantAsync(It.IsAny <string>())).ReturnsAsync(tenant);
            mockSurveyAnswerStore.Setup(r => r.GetFirstSurveyAnswerIdAsync(It.IsAny <string>(), It.IsAny <string>())).ReturnsAsync(string.Empty);

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, mockTenantStore.Object, null))
            {
                var result = await controller.ExportResponses(string.Empty) as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData <ExportResponseModel>;

                Assert.AreSame(tenant, model.ContentModel.Tenant);
            }
        }