Ejemplo n.º 1
0
        public async Task GetSurveyAnswerCreatesBlobContainerForGivenTenantAndSurvey()
        {
            var mockSurveyContainerFactory = new Mock <ISurveyAnswerContainerFactory>();
            var store = new SurveyAnswerStore(
                new Mock <ITenantStore>().Object,
                mockSurveyContainerFactory.Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureBlobContainer <List <string> > >().Object);

            mockSurveyContainerFactory.Setup(f => f.Create(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Mock <IAzureBlobContainer <SurveyAnswer> >().Object);

            await store.GetSurveyAnswerAsync("tenant", "slug-name", string.Empty);

            mockSurveyContainerFactory.Verify(f => f.Create("tenant", "slug-name"));
        }
Ejemplo n.º 2
0
        public async Task GetSurveyAnswerGetsAnswerFromBlobContainer()
        {
            var mockSurveyAnswerBlobContainer = new Mock <IAzureBlobContainer <SurveyAnswer> >();
            var mockSurveyContainerFactory    = new Mock <ISurveyAnswerContainerFactory>();
            var store = new SurveyAnswerStore(
                new Mock <ITenantStore>().Object,
                mockSurveyContainerFactory.Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureBlobContainer <List <string> > >().Object);

            mockSurveyContainerFactory.Setup(f => f.Create(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(mockSurveyAnswerBlobContainer.Object);

            await store.GetSurveyAnswerAsync("tenant", "slug-name", "id");

            mockSurveyAnswerBlobContainer.Verify(c => c.GetAsync("id"));
        }
Ejemplo n.º 3
0
        public async Task GetSurveyAnswerReturnsAnswerObtainedFromBlobContainer()
        {
            var mockSurveyAnswerBlobContainer = new Mock <IAzureBlobContainer <SurveyAnswer> >();
            var mockSurveyContainerFactory    = new Mock <ISurveyAnswerContainerFactory>();
            var store = new SurveyAnswerStore(
                new Mock <ITenantStore>().Object,
                mockSurveyContainerFactory.Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureBlobContainer <List <string> > >().Object);

            mockSurveyContainerFactory.Setup(f => f.Create(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(mockSurveyAnswerBlobContainer.Object);
            var surveyAnswer = new SurveyAnswer();

            mockSurveyAnswerBlobContainer.Setup(c => c.GetAsync(It.IsAny <string>()))
            .ReturnsAsync(surveyAnswer);

            var actualSurveyAnswer = await store.GetSurveyAnswerAsync("tenant", "slug-name", string.Empty);

            Assert.AreSame(surveyAnswer, actualSurveyAnswer);
        }