Пример #1
0
        public void AppendSurveyAnswerIdsToAnswersListCreatesListWhenItDoesNotExistAndSavesIt()
        {
            var mockSurveyAnswerIdsListContainer = new Mock <IAzureBlobContainer <List <string> > >();
            var store = new SurveyAnswerStore(
                new Mock <ITenantStore>().Object,
                new Mock <ISurveyAnswerContainerFactory>().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                mockSurveyAnswerIdsListContainer.Object);

            List <string> answerIdsList = null;
            var           optContext    = It.IsAny <OptimisticConcurrencyContext>();

            mockSurveyAnswerIdsListContainer.Setup(c => c.Get("tenant-slug-name", out optContext)).Returns(answerIdsList);
            List <string> savedList = null;

            mockSurveyAnswerIdsListContainer.Setup(c => c.Save(optContext, It.IsAny <List <string> >()))
            .Callback <IConcurrencyControlContext, List <string> >((id, l) => savedList = l);

            store.AppendSurveyAnswerIdsToAnswersList("tenant", "slug-name", new List <string>()
            {
                "new id"
            });

            Assert.AreEqual(1, savedList.Count);
            Assert.AreEqual("new id", savedList.Last());
        }
        public void AppendSurveyAnswerIdsToAnswersListGetTheAnswersListBlob()
        {
            var mockSurveyAnswerIdsListContainer = new Mock<IAzureBlobContainer<List<string>>>();
            var store = new SurveyAnswerStore(
                new Mock<ITenantStore>().Object,
                new Mock<ISurveyAnswerContainerFactory>().Object,
                new Mock<IAzureQueue<SurveyAnswerStoredMessage>>().Object,
                new Mock<IAzureQueue<SurveyAnswerStoredMessage>>().Object,
                mockSurveyAnswerIdsListContainer.Object);

            store.AppendSurveyAnswerIdsToAnswersList("tenant", "slug-name", new List<string>());

            var optContext = It.IsAny<OptimisticConcurrencyContext>();
            mockSurveyAnswerIdsListContainer.Verify(c => c.Get("tenant-slug-name", out optContext), Times.Once());
        }
Пример #3
0
        public void AppendSurveyAnswerIdsToAnswersListGetTheAnswersListBlob()
        {
            var mockSurveyAnswerIdsListContainer = new Mock <IAzureBlobContainer <List <string> > >();
            var store = new SurveyAnswerStore(
                new Mock <ITenantStore>().Object,
                new Mock <ISurveyAnswerContainerFactory>().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                new Mock <IAzureQueue <SurveyAnswerStoredMessage> >().Object,
                mockSurveyAnswerIdsListContainer.Object);

            store.AppendSurveyAnswerIdsToAnswersList("tenant", "slug-name", new List <string>());

            var optContext = It.IsAny <OptimisticConcurrencyContext>();

            mockSurveyAnswerIdsListContainer.Verify(c => c.Get("tenant-slug-name", out optContext), Times.Once());
        }
        public void AppendSurveyAnswerIdsToAnswersListCreatesListWhenItDoesNotExistAndSavesIt()
        {
            var mockSurveyAnswerIdsListContainer = new Mock<IAzureBlobContainer<List<string>>>();
            var store = new SurveyAnswerStore(
                new Mock<ITenantStore>().Object,
                new Mock<ISurveyAnswerContainerFactory>().Object,
                new Mock<IAzureQueue<SurveyAnswerStoredMessage>>().Object,
                new Mock<IAzureQueue<SurveyAnswerStoredMessage>>().Object,
                mockSurveyAnswerIdsListContainer.Object);

            List<string> answerIdsList = null;
            var optContext = It.IsAny<OptimisticConcurrencyContext>();
            mockSurveyAnswerIdsListContainer.Setup(c => c.Get("tenant-slug-name", out optContext)).Returns(answerIdsList);
            List<string> savedList = null;
            mockSurveyAnswerIdsListContainer.Setup(c => c.Save(optContext, It.IsAny<List<string>>()))
                                            .Callback<IConcurrencyControlContext, List<string>>((id, l) => savedList = l);

            store.AppendSurveyAnswerIdsToAnswersList("tenant", "slug-name", new List<string>() { "new id" });

            Assert.AreEqual(1, savedList.Count);
            Assert.AreEqual("new id", savedList.Last());
        }