示例#1
0
        public void TileFetcherWithFailingFetchesTest()
        {
            // Arrange
            var tileProvider = new SometimesFailingTileProvider();
            var tileSchema   = new GlobalSphericalMercator();
            var tileSource   = new TileSource(tileProvider, tileSchema);
            var tileFetcher  = new TileFetcher(tileSource, new MemoryCache <Feature>());

            // Act
            for (int i = 0; i < 100; 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 == true)
            {
            }
            ;

            Assert.Pass("The fetcher did not go into an infinite loop");
        }
示例#2
0
        public void TileFetcherWithFailingFetchesTest()
        {
            // Arrange
            var tileProvider = new SometimesFailingTileProvider();
            var tileSchema = new GlobalSphericalMercator();
            var tileSource =  new TileSource(tileProvider, tileSchema);
            var tileFetcher = new TileFetcher(tileSource, new MemoryCache<Feature>());

            // Act
            for (int i = 0; i < 100; 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");
        }
示例#3
0
        public void TileFetcherWithSometimesFailingFetchesShouldTryAgain()
        {
            // Arrange
            var tileProvider = new SometimesFailingTileProvider();
            var tileSchema   = new GlobalSphericalMercator();
            var tileSource   = new TileSource(tileProvider, tileSchema);

            using var cache = new MemoryCache <IFeature?>();
            var fetchDispatcher = new TileFetchDispatcher(cache, tileSource.Schema, tileInfo => TileToFeature(tileSource, tileInfo));
            var tileMachine     = new FetchMachine(fetchDispatcher);
            var level           = 3;
            var tilesInLevel    = 64;
            var fetchInfo       = new FetchInfo(tileSchema.Extent.ToMRect(), tileSchema.Resolutions[level].UnitsPerPixel);

            // Act
            fetchDispatcher.SetViewport(fetchInfo);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
                Thread.Sleep(1);
            }

            var tileCountAfterFirstBatch = tileProvider.TotalCount;

            // Act again
            fetchDispatcher.SetViewport(fetchInfo);
            tileMachine.Start();
            while (fetchDispatcher.Busy)
            {
                Thread.Sleep(1);
            }

            // Assert
            Assert.GreaterOrEqual(tileProvider.TotalCount, tileCountAfterFirstBatch);
            Assert.GreaterOrEqual(tileProvider.CountByTile.Values.Sum(), tilesInLevel);
        }