public void SetUp() { var interval = 1000; //if you run all tests, set it 10000+ miliseconds, or use several keys _apiHttpClient = HttpClientManager.GetRateLimitClient(@"https://www.alphavantage.co/query", interval, 7); _connectorReal = new AlphaVantageConnector.AlphaVantageConnector(_apiKeyServiceMock.Object, _apiHttpClient); _alphaVantageServiceReal = new AlphaVantageService(_connectorReal); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var apiHttpClient = HttpClientManager.GetRateLimitClient(@"https://www.alphavantage.co/query", rateLimit: 1000, maxConcurrentRequests: 7); services.AddSingleton(x => apiHttpClient); services.AddSingleton <IApiKeyService, ApiKeyService>(); services.AddSingleton <IAlphaVantageConnector, AlphaVantageConnector.AlphaVantageConnector>(); services.AddScoped <IAlphaVantageService, AlphaVantageService>(); services.AddControllers(); services.AddSwaggerGen(q => { q.SwaggerDoc("v1", new OpenApiInfo { Title = "Analytics API V0.01", Version = "0.01" }); var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var commentsFileName = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var commentsFile = Path.Combine(baseDirectory, commentsFileName); q.IncludeXmlComments(commentsFile); }); }