public WebHookPublisher(WebHookPublisherSettings settings)
 {
     _settings           = settings ?? throw new ArgumentNullException(nameof(settings));
     _webHooksRepository = new WebHooksRepository(settings.StreamStore, "webhooks", settings.GetUtcNow,
                                                  settings.MaxWebHookCount);
     _httpClient     = new HttpClient(settings.HttpMessageHandler);
     _streamStore    = settings.StreamStore;
     _webHookHeaders = new WebHookHeaders(settings.Vendor);
 }
        public PublisherTests()
        {
            // Setup subscriber
            _subscriberStreamStore = new InMemoryStreamStore(() => _utcNow);
            _subscriberSettings    = new WebHookSubscriberSettings(_subscriberStreamStore);
            var subscriberWebHostBuilder = new WebHostBuilder()
                                           .UseStartup <WebHookSubscriberStartup>()
                                           .ConfigureServices(services => services.AddSingleton(_subscriberSettings));
            var subscriberTestServer = new TestServer(subscriberWebHostBuilder);

            _subscriberClient = new HttpClient(subscriberTestServer.CreateHandler())
            {
                BaseAddress = new Uri("http://subscriber.example.com")
            };

            // Setup publisher
            _publisherStreamStore = new InMemoryStreamStore(() => _utcNow);
            var publisherSettings = new WebHookPublisherSettings(_publisherStreamStore)
            {
                HttpMessageHandler = subscriberTestServer.CreateHandler(),
                GetUtcNow          = () => _utcNow
            };

            _publisher = new WebHookPublisher(publisherSettings);
            var publisherWebHostBuilder = new WebHostBuilder()
                                          .UseStartup <WebHookPublisherStartup>()
                                          .ConfigureServices(services => services.AddSingleton(publisherSettings));
            var publisherTestServer = new TestServer(publisherWebHostBuilder);

            _publisherClient = new HttpClient(publisherTestServer.CreateHandler())
            {
                BaseAddress = new Uri("http://publisher.example.com")
            };
            _publisherClient.DefaultRequestHeaders.Accept.Add(
                MediaTypeWithQualityHeaderValue.Parse("application/json"));
        }
예제 #3
0
 public WebHookPublisherStartup(WebHookPublisherSettings settings)
 {
     _settings = settings;
 }