Пример #1
0
        public void DownloadAndReadMetadata_Should_schedule_http_notification()
        {
            // Arrange
            var jobsHelper = new JobsHelper(_context, _downloader, _metadataReader, _client, _postNotificationSender);

            // Act
            jobsHelper.DownloadAndReadMetadata(1);

            // Assert
            Mock.Get(_client).Verify(c => c.Create(It.IsAny <Job>(), It.IsAny <IState>()));
        }
Пример #2
0
        public void DownloadAndReadMetadata_Should_get_scheduled_image_from_db_and_process_it()
        {
            // Arrange
            var jobsHelper = new JobsHelper(_context, _downloader, _metadataReader, _client, _postNotificationSender);

            // Act
            jobsHelper.DownloadAndReadMetadata(1);

            // Assert
            Mock.Get(_scheduledImages).Verify(x => x.Find(It.Is <int>(id => id == 1)));
            Mock.Get(_downloader).Verify(x => x.Download(It.IsAny <string>()));
            Mock.Get(_metadataReader).Verify(x => x.ReadFromStream(It.IsAny <MemoryStream>()));
        }
        private void ScheduleBackgroundJob(ScheduledImage imageMetadata)
        {
            var helper = new JobsHelper(_context, new DownloadToStream(), new CustomMetadataReader(), _backgroundJobClient, _postNotificationSender);

            _backgroundJobClient.Enqueue(() => helper.DownloadAndReadMetadata(imageMetadata.Id));
        }