Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Fact]
- public void FetchImageFromSiteCommandTest()
- {
- // Replace the immediate scheduler with an event loop (a thread who just
- // waits in the background to process stuff as it arrives, one at a time)
- var origSched = RxApp.DeferredScheduler;
- RxApp.DeferredScheduler = new EventLoopScheduler();
- // MyCoolViewModel has an ICommand called FetchImageFromSite
- var fixture = new MyCoolViewModel();
- fixture.FetchImageFromSite("myCoolImage.jpg").Execute();
- // While it's running, make sure we can't execute anything
- Assert.False(fixture.FetchImageFromSite.CanExecute("myCoolImage.jpg"));
- Assert.False(fixture.DownloadedImages.Any(x => x.Name == "myCoolImage.jpg"));
- // Wait until it completes
- fixture.FetchImageFromSite.ItemsInflight
- .Where(count => count == 0)
- .First();
- // Verify that the Image is downloaded
- Assert.True(fixture.DownloadedImages.Any(x => x.Name == "myCoolImage"));
- // Now we *should* be able to execute the command
- Assert.True(fixture.FetchImageFromSite.CanExecute("myCoolImage.jpg"));
- // Replace the old scheduler
- RxApp.DeferredScheduler = origSched;
- }
Add Comment
Please, Sign In to add comment