public void PostRunAddsTheAnswerIdToTheListInTheStore() { var mockTenantSurveyProcessingInfoCache = new Mock <IDictionary <string, TenantSurveyProcessingInfo> >(); var mockUpdateableQueue = new Mock <IUpdateableAzureQueue>(); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); var mockSurveyAnswersSummaryStore = new Mock <ISurveyAnswersSummaryStore>(); var command = new UpdatingSurveyResultsSummaryCommand(mockTenantSurveyProcessingInfoCache.Object, mockSurveyAnswerStore.Object, mockSurveyAnswersSummaryStore.Object); var message = new SurveyAnswerStoredMessage { Tenant = "tenant", SurveySlugName = "slug-name", SurveyAnswerBlobId = "id", AppendedToAnswers = false }; message.SetUpdateableQueueReference(mockUpdateableQueue.Object); var tenantSurveyProcessingInfo = new TenantSurveyProcessingInfo("tenant", "slug-name"); tenantSurveyProcessingInfo.AnswersMessages.Add(message); mockTenantSurveyProcessingInfoCache.Setup(c => c.Values).Returns(new[] { tenantSurveyProcessingInfo }); command.PostRun(); mockSurveyAnswerStore.Verify( r => r.AppendSurveyAnswerIdsToAnswersList("tenant", "slug-name", It.IsAny <IEnumerable <string> >()), Times.Once()); mockUpdateableQueue.Verify(q => q.UpdateMessage(message), Times.Once()); }
public void PostRunMergesTheSummaryToTheStore() { var mockTenantSurveyProcessingInfoCache = new Mock <IDictionary <string, TenantSurveyProcessingInfo> >(); var mockSurveyAnswerStore = new Mock <ISurveyAnswerStore>(); var mockSurveyAnswersSummaryStore = new Mock <ISurveyAnswersSummaryStore>(); var command = new UpdatingSurveyResultsSummaryCommand(mockTenantSurveyProcessingInfoCache.Object, mockSurveyAnswerStore.Object, mockSurveyAnswersSummaryStore.Object); var tenantSurveyProcessingInfo = new TenantSurveyProcessingInfo("tenant", "slug-name"); mockTenantSurveyProcessingInfoCache.Setup(c => c.Values).Returns(new[] { tenantSurveyProcessingInfo }); command.PostRun(); mockSurveyAnswersSummaryStore.Verify( r => r.MergeSurveyAnswersSummary(It.Is <SurveyAnswersSummary>(s => s == tenantSurveyProcessingInfo.AnswersSummary)), Times.Once()); }