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

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

                Assert.AreEqual(result.RouteValues["action"], "BrowseResponses");
            }
        }
        public void ExportGetsTheTenantInformationAndPutsInModel()
        {
            var tenant = new Tenant();

            var mockTenantStore = new Mock<ITenantStore>();
            var mockSurveyAnswerStore = new Mock<ISurveyAnswerStore>();
            mockTenantStore.Setup(r => r.GetTenant(It.IsAny<string>())).Returns(tenant);
            mockSurveyAnswerStore.Setup(r => r.GetFirstSurveyAnswerId(It.IsAny<string>(), It.IsAny<string>())).Returns(string.Empty);

            using (var controller = new SurveysController(null, mockSurveyAnswerStore.Object, null, mockTenantStore.Object, null, null))
            {
                controller.Tenant = tenant;

                var result = controller.ExportResponses(string.Empty) as ViewResult;

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

                Assert.AreSame(tenant, model.ContentModel.Tenant);
            }
        }
        public void ExportPostCallsTransferPostWithTenantAndSlugName()
        {
            var mockSurveyTransferStore = new Mock<ISurveyTransferStore>();

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

            mockSurveyTransferStore.Verify(r => r.Transfer("tenant", "slugName"), Times.Once());
        }
        public void ExportDeterminesIfThereAreResponsesToExport()
        {
            var mockTenantStore = new Mock<ITenantStore>();
            var mockSurveyAnswerStore = new Mock<ISurveyAnswerStore>();
            var tenant = new Tenant();
            mockTenantStore.Setup(r => r.GetTenant(It.IsAny<string>())).Returns(tenant);
            mockSurveyAnswerStore.Setup(r => r.GetFirstSurveyAnswerId(It.IsAny<string>(), It.IsAny<string>())).Returns(string.Empty);

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

                var model = result.ViewData.Model as TenantPageViewData<ExportResponseModel>;
                Assert.AreEqual(false, model.ContentModel.HasResponses);
            }
        }