示例#1
0
        public void RunGetsSurveyAnswerIdsFromStore()
        {
            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);
            var tenant = new Tenant {
                SqlAzureConnectionString = "connectionString"
            };

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

            command.Run(message);

            mockSurveyAnswerStore.Verify(r => r.GetSurveyAnswerIdsAsync(message.Tenant, "slugName"));
        }
        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"));
        }
示例#3
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.GetTenantAsync("tenant")).ReturnsAsync(tenant);
            mockSurveyStore.Setup(r => r.GetSurveyByTenantAndSlugNameAsync("tenant", "slugName", true)).ReturnsAsync(new Survey());

            command.Run(message);

            mockSurveyStore.Verify(r => r.GetSurveyByTenantAndSlugNameAsync(message.Tenant, message.SlugName, true));
        }
        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));
        }