示例#1
0
 // ReSharper disable once SuggestBaseTypeForParameter
 public QueuedGenericService(
     ILogger <QueuedGenericService <TInput> > logger,
     IOptions <QueuedGenericServiceOptions>?options,
     IHostApplicationLifetime hostApplicationLifetime,
     IBackgroundTaskQueue <MotorCloudEvent <TInput> > queue,
     BaseDelegatingMessageHandler <TInput> rootService)
 {
     _logger  = logger;
     _options = options?.Value ?? new QueuedGenericServiceOptions();
     _hostApplicationLifetime = hostApplicationLifetime;
     _queue       = queue;
     _rootService = rootService;
 }
        private static QueuedGenericService <string> CreateQueuedGenericService(
            INoOutputService <string> service = null,
            IBackgroundTaskQueue <MotorCloudEvent <string> > backgroundTaskQueue = null,
            IHostApplicationLifetime hostApplicationLifetime = null,
            QueuedGenericServiceOptions config = null)
        {
            var logger = new Mock <ILogger <QueuedGenericService <string> > >();

            hostApplicationLifetime ??= new Mock <IHostApplicationLifetime>().Object;
            backgroundTaskQueue ??= CreateQueue();
            service ??= new Mock <INoOutputService <string> >().Object;
            var options = new OptionsWrapper <QueuedGenericServiceOptions>(config ?? new QueuedGenericServiceOptions());
            var baseDelegatingMessageHandler = CreateBaseDelegatingMessageHandler(service);

            return(new QueuedGenericService <string>(
                       logger.Object,
                       options,
                       hostApplicationLifetime,
                       backgroundTaskQueue,
                       baseDelegatingMessageHandler));
        }