public void SetUp() { _enrichmentServiceMock = new Mock <IEnrichmentService>(); _dataServiceMock = new Mock <IDataService>(); _loggerMock = new Mock <ILogger <SearchAndCompareService> >(); _httpMock = new Mock <IHttpClient>(); var searchAndCompareApi = new SearchAndCompareApi(_httpMock.Object, sncUrl); _searchAndCompareService = new SearchAndCompareService(searchAndCompareApi, new CourseMapper(), _dataServiceMock.Object, _enrichmentServiceMock.Object, _loggerMock.Object); }
private async Task PublishToSearch(IList <SearchCourse> courses) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _mcConfig.SearchAndCompareApiKey); httpClient.Timeout = TimeSpan.FromMinutes(120); var client = new SearchAndCompareApi(httpClient, _mcConfig.SearchAndCompareApiUrl); _logger.Information($"Sending {courses.Count()} courses to Search API..."); var success = await client.SaveCoursesAsync(courses); if (!success) { throw new Exception("Publishing to Search API failed. Check search API logs for details"); } } }
public void SetUp() { mockHttp = new Mock <IHttpClient>(); sut = new SearchAndCompareApi(mockHttp.Object, "https://api.example.com"); }