public async Task IndexReturnsTheSurveysForTheTenantInTheModel()
        {
            var mockSurveyStore = new Mock <ISurveyStore>();

            mockSurveyStore.Setup(r => r.GetSurveysByTenantAsync(It.IsAny <string>()))
            .ReturnsAsync(new List <Survey>()
            {
                new Survey()
                {
                    Title = "title"
                }
            });

            var mockTenantStore = new Mock <ITenantStore>();

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

            using (var controller = new SurveysController(mockSurveyStore.Object, null, null, mockTenantStore.Object, null))
            {
                var result = await controller.Index() as ViewResult;

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

                Assert.AreEqual(1, model.ContentModel.Count());
                Assert.AreEqual("title", model.ContentModel.First().Title);
            }
        }
Beispiel #2
0
        public void IndexReturnsEmptyViewName()
        {
            using (var controller = new SurveysController(new Mock <ISurveyStore>().Object, null, null, null, null))
            {
                var result = controller.Index() as ViewResult;

                Assert.AreEqual(string.Empty, result.ViewName);
            }
        }
Beispiel #3
0
        public void IndexReturnsMySurveysAsTitleInTheModel()
        {
            using (var controller = new SurveysController(new Mock <ISurveyStore>().Object, null, null, null, null))
            {
                var result = controller.Index() as ViewResult;

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreSame("My Surveys", model.Title);
            }
        }
Beispiel #4
0
        public void IndexGetsRecentSurveysFromStore()
        {
            var mockSurveyStore = new Mock <ISurveyStore>();

            using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore)))
            {
                controller.Index();
            }

            mockSurveyStore.Verify(r => r.GetRecentSurveys(), Times.Once());
        }
Beispiel #5
0
        public void IndexReturnsTitleInTheModel()
        {
            var mockSurveyStore = new Mock <ISurveyStore>();

            using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore)))
            {
                var result = controller.Index() as ViewResult;

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreEqual("Existing surveys", model.Title);
            }
        }
Beispiel #6
0
        public void IndexCallsGetAllSurveysByTenantFromSurveyStore()
        {
            var mockSurveyStore = new Mock <ISurveyStore>();

            using (var controller = new SurveysController(mockSurveyStore.Object, null, null, null, null))
            {
                controller.TenantName = "tenant";

                controller.Index();
            }

            mockSurveyStore.Verify(r => r.GetSurveysByTenant(It.Is <string>(actual => "tenant" == actual)), Times.Once());
        }
        public async Task IndexReturnsEmptyViewName()
        {
            var mockTenantStore = new Mock <ITenantStore>();

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

            using (var controller = new SurveysController(new Mock <ISurveyStore>().Object, null, null, mockTenantStore.Object, null))
            {
                var result = await controller.Index() as ViewResult;

                Assert.AreEqual(string.Empty, result.ViewName);
            }
        }
        public async Task IndexGetsRecentSurveysFromStore()
        {
            var mockSurveyManagementService = new Mock <ISurveyManagementService>();
            var surveys = new List <Tailspin.SurveyManagementService.Client.Models.SurveyInformation>();

            mockSurveyManagementService.Setup(r => r.GetLatestSurveysAsync()).ReturnsAsync(surveys);

            using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object))
            {
                await controller.Index();
            }

            mockSurveyManagementService.Verify(r => r.GetLatestSurveysAsync(), Times.Once());
        }
        public async Task IndexReturnsMySurveysAsTitleInTheModel()
        {
            var mockTenantStore = new Mock <ITenantStore>();

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

            using (var controller = new SurveysController(new Mock <ISurveyStore>().Object, null, null, mockTenantStore.Object, null))
            {
                var result = await controller.Index() as ViewResult;

                var model = result.ViewData.Model as TenantMasterPageViewData;
                Assert.AreSame("My Surveys", model.Title);
            }
        }
Beispiel #10
0
        public void IndexReturnsRecentSurveysFromStoreInTheModel()
        {
            var mockSurveyStore = new Mock <ISurveyStore>();
            var surveys         = new List <Survey>();

            mockSurveyStore.Setup(r => r.GetRecentSurveys()).Returns(surveys);

            using (var controller = new SurveysController(mockSurveyStore.Object, default(ISurveyAnswerStore)))
            {
                var result = controller.Index() as ViewResult;

                var model = result.ViewData.Model as TenantPageViewData <IEnumerable <Survey> >;
                Assert.AreSame(surveys, model.ContentModel);
            }
        }
        public async Task IndexReturnsRecentSurveysFromStoreInTheModel()
        {
            var mockSurveyManagementService = new Mock <ISurveyManagementService>();
            var surveys = new List <Tailspin.SurveyManagementService.Client.Models.SurveyInformation>();

            mockSurveyManagementService.Setup(r => r.GetLatestSurveysAsync()).ReturnsAsync(surveys);

            using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object))
            {
                var result = await controller.Index() as ViewResult;

                var model = result.ViewData.Model as PageViewData <IEnumerable <Survey> >;
                Assert.IsNotNull(model.ContentModel);
            }
        }
        public async Task IndexReturnsTitleInTheModel()
        {
            var mockSurveyManagementService = new Mock <ISurveyManagementService>();
            var surveys = new List <Tailspin.SurveyManagementService.Client.Models.SurveyInformation>();

            mockSurveyManagementService.Setup(r => r.GetLatestSurveysAsync()).ReturnsAsync(surveys);

            using (var controller = new SurveysController(mockSurveyManagementService.Object, new Mock <ISurveyAnswerService>().Object))
            {
                var result = await controller.Index() as ViewResult;

                var model = result.ViewData.Model as MasterPageViewData;
                Assert.AreEqual("Existing surveys", model.Title);
            }
        }
        public async Task IndexCallsGetAllSurveysByTenantFromSurveyStore()
        {
            var mockSurveyStore = new Mock <ISurveyStore>();
            var mockTenantStore = new Mock <ITenantStore>();

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

            using (var controller = new SurveysController(mockSurveyStore.Object, null, null, mockTenantStore.Object, null))
            {
                controller.TenantId = "tenant";

                await controller.Index();
            }

            mockSurveyStore.Verify(r => r.GetSurveysByTenantAsync(It.Is <string>(actual => "tenant" == actual)), Times.Once());
        }