public void DropAllPendingTileRequests_TileFetcherIsProcessingRequests_RequestsAreDropped() { // Setup var info = new TileInfo(); var data = new byte[0]; using (var blockingEvent = new ManualResetEvent(false)) { var blockingTileProvider = new TileProviderStub(blockingEvent) { TileDataToReturn = data }; using (var fetcherIsDoneEvent = new ManualResetEvent(false)) using (var fetcher = new AsyncTileFetcher(blockingTileProvider, 100, 200)) { fetcher.TileReceived += (sender, args) => fetcherIsDoneEvent.Set(); fetcher.QueueEmpty += (sender, args) => fetcherIsDoneEvent.Set(); byte[] fetchedData = fetcher.GetTile(info); // Precondition Assert.IsNull(fetchedData); // Call fetcher.DropAllPendingTileRequests(); Assert.IsFalse(fetcherIsDoneEvent.WaitOne(allowedTileFetchTime), "TileFetcher should have dropped request."); } } }
public void DropAllPendingTileRequests_TileFetcherDisposed_ThrowObjectDisposedException() { // Setup var mocks = new MockRepository(); var tileProvider = mocks.Stub <ITileProvider>(); mocks.ReplayAll(); var tileFetcher = new AsyncTileFetcher(tileProvider, 1, 2); tileFetcher.Dispose(); // Call TestDelegate call = () => tileFetcher.DropAllPendingTileRequests(); // Assert string objectName = Assert.Throws <ObjectDisposedException>(call).ObjectName; Assert.AreEqual("AsyncTileFetcher", objectName); mocks.VerifyAll(); }