internal static void PutHttpSenderOptionsInPool <T>(this IServiceCollection services, HttpSenderOptions options)
        {
            services.TryAddSingleton <IHttpSenderOptionsPool>(HttpSenderOptionsPool.CreateInstance());

            var pool = services.BuildServiceProvider().GetService <IHttpSenderOptionsPool>();

            if (pool == null)
            {
                throw new ArgumentNullException();
            }

            pool.Put <T>(options);
        }
Example #2
0
        public HttpXmlUnitTest()
        {
            if (string.IsNullOrEmpty(BaseAddress))
            {
                throw new ArgumentNullException($"Empty test params");
            }

            _optionsProvider = CreateHttpSenderOptions();
            _httpClient      = CreateHttpClient(_optionsProvider.BaseAddress);
            _nullRepoLogger  = new NullLoggerFactory().CreateLogger <HttpSenderXml>();
            _responseFactory = new ResponseFactory();
            _optionsPool     = HttpSenderOptionsPool.CreateInstance <ConcreteHttpSenderXml>(_optionsProvider.SenderOptions);

            _xmlSender = new ConcreteHttpSenderXml(_httpClient, _optionsPool, _responseFactory, _nullRepoLogger);
        }