public void TileFetcherShouldBehaveProperlyWithNoisyResponses() { // Arrange var schema = new GlobalSphericalMercator(); var tileSource = new TileSource(new SometimesFailingTileProvider(), schema); var memoryCache = new MemoryCache<Feature>(14, 17); var tileFetcher = new TileFetcher(tileSource, memoryCache); var random = new Random(31747074); // Act for (int i = 0; i < 100; i++) { var randomLevel = "5"; var randomCol = random.Next(schema.GetMatrixWidth(randomLevel)); var randomRow = random.Next(schema.GetMatrixHeight(randomLevel)); var tileRange = new TileRange(randomCol - 2, randomRow - 2, 5, 5); var unitsPerPixel = schema.Resolutions[randomLevel].UnitsPerPixel; var extent = TileTransform.TileToWorld(tileRange, randomLevel, schema); tileFetcher.ViewChanged(TileTransform.TileToWorld(tileRange, randomLevel, schema).ToBoundingBox(),unitsPerPixel ); var tileInfos = schema.GetTileInfos(extent, randomLevel); foreach (var tileInfo in tileInfos) { var tiles = memoryCache.Find(tileInfo.Index); } } // Assert Assert.True(memoryCache.TileCount == 0); }
public void TileFetcherShouldBehaveProperlyWithFailingTileRequests() { // Arrange var schema = new GlobalSphericalMercator(); var tileSource = new TileSource(new FailingTileProvider(), schema); var memoryCache = new MemoryCache<Feature>(); var tileFetcher = new TileFetcher(tileSource, memoryCache); // Act tileFetcher.ViewChanged(schema.Extent.ToBoundingBox(), schema.Resolutions["2"].UnitsPerPixel); while (tileFetcher.Busy) { } // Assert Assert.True(memoryCache.TileCount == 0); }
protected void SetTileSource(ITileSource source) { if (_tileSource != null) { _tileFetcher.AbortFetch(); _tileFetcher.DataChanged -= TileFetcherDataChanged; _tileFetcher.PropertyChanged -= TileFetcherOnPropertyChanged; _tileFetcher = null; _memoryCache.Clear(); } _tileSource = source; if (source == null) return; _tileFetcher = new TileFetcher(source, _memoryCache, _maxRetries, _maxThreads, _fetchStrategy); _tileFetcher.DataChanged += TileFetcherDataChanged; _tileFetcher.PropertyChanged += TileFetcherOnPropertyChanged; OnPropertyChanged("Envelope"); }
public void TileFetcherWithReturningNull() { // Arrange var tileProvider = new NullTileProvider(); var tileSchema = new GlobalSphericalMercator(); var tileSource = new TileSource(tileProvider, tileSchema); var tileFetcher = new TileFetcher(tileSource, new MemoryCache<Feature>()); // Act for (int i = 0; i < 300; i++) { for (int j = 0; j < 5; j++) { tileFetcher.ViewChanged(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[j.ToString()].UnitsPerPixel); System.Threading.Thread.Sleep(10); } } // Assert while (tileFetcher.Busy) { } Assert.Pass("The fetcher did not go into an infinite loop"); }
protected void SetTileSource(ITileSource source) { if (_tileSource != null) { // Is causing thread leak _tileFetcher.AbortFetch(); _tileFetcher.DataChanged -= TileFetcherDataChanged; _tileFetcher.PropertyChanged -= TileFetcherOnPropertyChanged; _tileFetcher = null; _memoryCache.Clear(); } _tileSource = source; if (_tileSource != null) { Attribution.Text = _tileSource.Attribution.Text; Attribution.Url = _tileSource.Attribution.Url; _tileFetcher = new TileFetcher(source, _memoryCache, _maxRetries, _maxThreads, _fetchStrategy); _tileFetcher.DataChanged += TileFetcherDataChanged; _tileFetcher.PropertyChanged += TileFetcherOnPropertyChanged; OnPropertyChanged(nameof(Envelope)); } }
protected void SetTileSource(ITileSource source) { tileSource = source; tileFetcher = new TileFetcher(source, memoryCache, maxRetries); tileFetcher.DataChanged += TileFetcherDataChanged; OnPropertyChanged("Envelope"); }