public void HorriblyBadVeryNaiveSortOfIntegrationTest() { var dataService = new MarketplaceDataService(); var cacheManager = new Cache.CacheManager <IExtensionDataItemView, ExtensionDataItem>(CacheFilePath); dataService.GetMarketplaceDataItems( "15.0", new[] { "Pro", "Ultimate" }, DateTime.MinValue, (items) => { cacheManager.AddRange(items); return(true); }); // Hit the back-end and check for actual results and write them to disk. // Without knowing what to expect, we can't validate these (other than by hand) // but a non-zero list is a good sign :) Assert.IsTrue(cacheManager.Snapshot.Count > 500); var itemsCount = cacheManager.Snapshot.Count; Assert.IsTrue(cacheManager.TrySaveCacheFile()); cacheManager.ReplaceAll(Enumerable.Empty <IExtensionDataItemView>()); Assert.IsTrue(cacheManager.Snapshot.Count == 0); Assert.IsTrue(cacheManager.TryLoadCacheFile()); Assert.AreEqual(itemsCount, cacheManager.Snapshot.Count); }
private static void RefreshCache() { if (cacheManager == null) { throw new InvalidOperationException("Cache has not yet been initialized"); } // Clear the list. cacheManager.ReplaceAll(System.Linq.Enumerable.Empty <IExtensionDataItemView>()); // TODO: correct SKU information. // TODO: incremental. marketPlaceService.GetMarketplaceDataItems( VsEditionUtil.GetCurrentVsVersion(), VsEditionUtil.GetSkusList(), DateTime.MinValue, (items) => { cacheManager.AddRange(items); return(true); }); try { Directory.CreateDirectory(Utilities.ExtensionAppDataPath); cacheManager.TrySaveCacheFile(); } catch { Debug.Fail("Failed to create local app data directory"); } }