public PackageLagTelemetryService(ITelemetryClient telemetryClient, PackageLagMonitorConfiguration configuration) { _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); _subscription = configuration.Subscription ?? ""; }
public PackageLagCatalogLeafProcessorFacts(ITestOutputHelper output) { _output = output; _searchServiceClient = new Mock <ISearchServiceClient>(); _azureManagementAPIWrapper = new Mock <IAzureManagementAPIWrapper>(); _telemetryService = new Mock <IPackageLagTelemetryService>(); _configurationMock = new Mock <IOptionsSnapshot <PackageLagMonitorConfiguration> >(); _httpClientMock = new Mock <IHttpClientWrapper>(); _configuration = new PackageLagMonitorConfiguration { InstancePortMinimum = 801, ServiceIndexUrl = "http://localhost:801/search/diag", Subscription = _subscription, RegionInformations = new List <RegionInformation> { new RegionInformation { Region = _region, ResourceGroup = _resourceGroup, ServiceName = _serviceName, }, } }; _logger = new LoggerFactory() .AddXunit(_output) .CreateLogger <PackageLagCatalogLeafProcessor>(); _token = CancellationToken.None; _instances = new List <Instance> { new Instance( _slot, 0, "http://localhost:801/search/diag", "http://localhost:801/query", _region), new Instance( _slot, 1, "http://localhost:802/search/diag", "http://localhost:802/query", _region) }; _feedTimestamp = new DateTimeOffset(2018, 1, 1, 8, 0, 0, TimeSpan.Zero); _configurationMock .Setup(x => x.Value) .Returns(() => _configuration); _searchServiceClient .Setup(x => x.GetSearchEndpointsAsync(It.IsAny <RegionInformation>(), It.IsAny <CancellationToken>())) .ReturnsAsync(() => _instances); var regionInformations = _configuration.RegionInformations; var instances = new List <Instance>(); foreach (var regionInformation in regionInformations) { instances.AddRange(_searchServiceClient.Object.GetSearchEndpointsAsync(regionInformation, _token).Result); } _target = new PackageLagCatalogLeafProcessor(instances, _searchServiceClient.Object, _telemetryService.Object, _logger); _target.WaitBetweenPolls = TimeSpan.FromSeconds(5); }