public CacheManager(IMemoryCache cache, ILogger <CacheManager> logger, RootDb rootDb, GuernseyDb guernseyDb) { _memoryCache = cache; _logger = logger; _rootDb = rootDb; _guernseyDb = guernseyDb; DataCategories = new CachableThing <DataCategoryDto[]>(nameof(DataCategories), _memoryCache, _rootDb.GetData); DataCache = new CachableThing <DataCache>(nameof(DataCache), _memoryCache, _guernseyDb.GetDataCache); LiveDataCache = new CachableThing <LiveDataCache>(nameof(LiveDataCache), _memoryCache, async() => { // TODO: Figure out good way to use the injected client using var client = new HttpClient(); var airportScraper = new AirportScraper(client); var airportScraperTask = airportScraper.Get(); var harbourScraper = new HarbourScraper(client); var harbourScraperTask = harbourScraper.Get(); var airportLatest = await airportScraperTask; var harbourLatest = await harbourScraperTask; return(new LiveDataCache { AirportArrivals = airportLatest.Arrivals, AirportDepartures = airportLatest.Departures, Harbour = harbourLatest, }); });
public async Task Harbour() { var scraper = new HarbourScraper(new HttpClient()); var res = await scraper.Get(); Assert.IsTrue(res.Length > 1); }