public async Task Should_Test_ExecutePubmedSearchConsumer()
        {
            //Arrange
            var pubmedWebClient = new Mock <IPubmedWebClient>();
            var mockFileService = new Mock <IFileService>();
            var mockUnitOfWork  = new Mock <ILsUnitOfWork>();
            var pubmedService   = new PubmedService(pubmedWebClient.Object, mockFileService.Object, mockUnitOfWork.Object);

            var harness         = new InMemoryTestHarness();
            var consumerHarness =
                harness.Consumer(() => new ExecutePubmedSearchConsumer(pubmedService));

            //Act
            await harness.Start();

            //Assert
            try
            {
                await harness.InputQueueSendEndpoint.Send <IExecutePubmedSearchCommand>(new
                {
                    ProjectId      = default(Guid),
                    LivingSearchId = default(Guid),
                    SearchTerm     = default(String),
                    BatchSize      = default(Int32)
                });

                Assert.True(harness.Consumed.Select <IExecutePubmedSearchCommand>().Any());
                Assert.True(consumerHarness.Consumed.Select <IExecutePubmedSearchCommand>().Any());
            }
            finally
            {
                await harness.Stop();
            }
        }
Ejemplo n.º 2
0
        public async void ExecutePubmedQueryAndSaveRecords_Should()
        {
            //Arrange
            var mockWebClient   = new Mock <IPubmedWebClient>();
            var mockFileService = new Mock <IFileService>();
            var mockUnitOfWork  = new Mock <ILsUnitOfWork>();

            mockWebClient
            .Setup(x => x.SubmitSearch("mice"))
            .Returns(Task.FromResult(new PubmedResultQueryDto {
                WebEnv = "env", QueryKey = "query", Count = 700
            }));

            var sut = new PubmedService(mockWebClient.Object, mockFileService.Object, mockUnitOfWork.Object);
            //Act
            var result = sut.FindNewPubmedStudiesAndSave(Guid.Empty, Guid.Empty, "desctiption", Guid.Empty, "mice", 500);

            //Assert
            Assert.IsAssignableFrom <IAsyncEnumerable <PubmedXmlFileInfoDto> >(result);
        }