public AmbariApiContentProvider(IOptions <AmbariClientConfiguration> configuration, ILogger <AmbariApiContentProvider> logger)
        {
            _configuration = configuration.Value;
            _logger        = logger;

            _httpClient = new HttpClient(new HttpClientHandler
            {
                Credentials             = new NetworkCredential(_configuration.Username, _configuration.Password),
                PreAuthenticate         = true,
                MaxConnectionsPerServer = 256,
            });
        }
Пример #2
0
        public ContentProviderTests()
        {
            var ambariConf = new AmbariClientConfiguration
            {
                Username = "******",
                Password = "******",
            };

            _configuration = new Mock <IOptions <AmbariClientConfiguration> >();
            _configuration.Setup(f => f.Value).Returns(ambariConf);
            _logger = new Mock <ILogger <AmbariApiContentProvider> >();

            _ambariApiContentProvider = new AmbariApiContentProvider(_configuration.Object, _logger.Object);
        }
        public void Validate_Attributes_Should_Pass(AmbariClientConfiguration conf, bool expectedResult)
        {
            try
            {
                conf.Validate();
            }
            catch (Exception e)
            {
                if (expectedResult)
                {
                    throw;
                }

                e.Should().BeOfType <AggregateException>();
            }
        }