public void RunGetsSurveyAnswersForIdFromStore()
        {
            var mockSurveyStore = new Mock<ISurveyStore>();
            var mockSurveyAnswerStore = new Mock<ISurveyAnswerStore>();
            var mockTenantStore = new Mock<ITenantStore>();
            var mockSurveySqlStore = new Mock<ISurveySqlStore>();
            var command = new TransferSurveysToSqlAzureCommand(mockSurveyAnswerStore.Object, mockSurveyStore.Object, mockTenantStore.Object, mockSurveySqlStore.Object);
            var message = new SurveyTransferMessage { Tenant = "tenant", SlugName = "slugName" };
            var survey = new Survey("slugName")
                             {
                                 Tenant = "tenant",
                             };
            survey.Questions.Add(new Question
                                     {
                                         Text = "What is your favorite food?",
                                         PossibleAnswers = "Coffee\nPizza\nSalad",
                                         Type = QuestionType.MultipleChoice
                                     });
            mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName("tenant", "slugName", true)).Returns(survey);
            mockSurveyStore.Setup(r => r.GetSurveysByTenant("tenant")).Returns(new List<Survey> { survey });
            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerIds("tenant", "slugName")).Returns(new List<string> { "id" });
            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswer("tenant", "slugName", "id")).Returns(new SurveyAnswer());
            var tenant = new Tenant { SqlAzureConnectionString = "connectionString" };
            mockTenantStore.Setup(r => r.GetTenant("tenant")).Returns(tenant);

            command.Run(message);

            mockSurveyAnswerStore.Verify(r => r.GetSurveyAnswer(message.Tenant, "slugName", "id"));
        }
Esempio n. 2
0
        public void RunGetsSurveyFromStore()
        {
            var mockSurveyStore       = new Mock <ISurveyStore>();
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();
            var mockTenantStore       = new Mock <ITenantStore>();
            var mockSurveySqlStore    = new Mock <ISurveySqlStore>();
            var command = new TransferSurveysToSqlAzureCommand(mockSurveyAnswerStore.Object, mockSurveyStore.Object, mockTenantStore.Object, mockSurveySqlStore.Object);
            var message = new SurveyTransferMessage {
                Tenant = "tenant", SlugName = "slugName"
            };
            var tenant = new Tenant {
                SqlAzureConnectionString = "connectionString"
            };

            mockTenantStore.Setup(r => r.GetTenant("tenant")).Returns(tenant);
            mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName("tenant", "slugName", true)).Returns(new Survey());

            command.Run(message);

            mockSurveyStore.Verify(r => r.GetSurveyByTenantAndSlugName(message.Tenant, message.SlugName, true));
        }
Esempio n. 3
0
        public void RunGetsSurveyAnswersForIdFromStore()
        {
            var mockSurveyStore       = new Mock <ISurveyStore>();
            var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>();
            var mockTenantStore       = new Mock <ITenantStore>();
            var mockSurveySqlStore    = new Mock <ISurveySqlStore>();
            var command = new TransferSurveysToSqlAzureCommand(mockSurveyAnswerStore.Object, mockSurveyStore.Object, mockTenantStore.Object, mockSurveySqlStore.Object);
            var message = new SurveyTransferMessage {
                Tenant = "tenant", SlugName = "slugName"
            };
            var survey = new Survey("slugName")
            {
                TenantId = "tenant",
            };

            survey.Questions.Add(new Question
            {
                Text            = "What is your favorite food?",
                PossibleAnswers = "Coffee\nPizza\nSalad",
                Type            = QuestionType.MultipleChoice
            });
            mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync("tenant", "slugName", true)).ReturnsAsync(survey);
            mockSurveyStore.Setup(r => r.GetSurveysByTenantAsync("tenant")).ReturnsAsync(new List <Survey> {
                survey
            });
            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerIdsAsync("tenant", "slugName")).ReturnsAsync(new List <string> {
                "id"
            });
            mockSurveyAnswerStore.Setup(r => r.GetSurveyAnswerAsync("tenant", "slugName", "id")).ReturnsAsync(new SurveyAnswer());
            var tenant = new Tenant {
                SqlAzureConnectionString = "connectionString"
            };

            mockTenantStore.Setup(r => r.GetTenantAsync("tenant")).ReturnsAsync(tenant);

            command.Run(message);

            mockSurveyAnswerStore.Verify(r => r.GetSurveyAnswerAsync(message.Tenant, "slugName", "id"));
        }
        public void RunGetsSurveyFromStore()
        {
            var mockSurveyStore = new Mock<ISurveyStore>();
            var mockSurveyAnswerStore = new Mock<ISurveyAnswerStore>();
            var mockTenantStore = new Mock<ITenantStore>();
            var mockSurveySqlStore = new Mock<ISurveySqlStore>();
            var command = new TransferSurveysToSqlAzureCommand(mockSurveyAnswerStore.Object, mockSurveyStore.Object, mockTenantStore.Object, mockSurveySqlStore.Object);
            var message = new SurveyTransferMessage { Tenant = "tenant", SlugName = "slugName" };
            var tenant = new Tenant { SqlAzureConnectionString = "connectionString" };
            mockTenantStore.Setup(r => r.GetTenant("tenant")).Returns(tenant);
            mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugName("tenant", "slugName", true)).Returns(new Survey());

            command.Run(message);

            mockSurveyStore.Verify(r => r.GetSurveyByTenantAndSlugName(message.Tenant, message.SlugName, true));
        }