public void Setup()
 {
     _processorOne = Substitute.For <ISearchIndexProcessor>();
     _processorOne.IndexWriterType.Returns("IndexOne");
     _processorTwo = Substitute.For <ISearchIndexProcessor>();
     _processorTwo.IndexWriterType.Returns("IndexTwo");
     _factory = new SearchIndexProcessorFactory(new[] { _processorOne, _processorTwo });
 }
 public void Setup()
 {
     _logger        = Substitute.For <ILogger>();
     _jobManagement = Substitute.For <IJobManagement>();
     _searchIndexProcessorFactory = Substitute.For <ISearchIndexProcessorFactory>();
     _service = new SearchIndexWriterService(_logger, _jobManagement, _searchIndexProcessorFactory);
     _searchIndexProcessor = Substitute.For <ISearchIndexProcessor>();
 }
Beispiel #3
0
        public override async Task Process(Message message)
        {
            Guard.ArgumentNotNull(message, nameof(message));

            try
            {
                string indexWriterType = message.GetUserProperty <string>("index-writer-type");

                if (string.IsNullOrWhiteSpace(indexWriterType))
                {
                    string errorMessage = $"Index-writer-type missing from SearchIndexWriter job. JobId {Job.Id}";
                    _logger.Error(errorMessage);
                    throw new Exception(errorMessage);
                }

                ISearchIndexProcessor processor = _searchIndexProcessorFactory.CreateProcessor(indexWriterType);
                await processor.Process(message);
            }
            catch (Exception exception)
            {
                _logger.Error(exception, $"Failed to run SearchIndexWriter with exception: {exception.Message}, for job id '{Job.Id}'");
                throw;
            }
        }
        public void ShouldReturnCorrectProcessor_WhenIndexProcessorAvailableForGivenIndexWriterType(string indexWriterType)
        {
            ISearchIndexProcessor processor = _factory.CreateProcessor(indexWriterType);

            processor.IndexWriterType.Should().Be(indexWriterType);
        }