public void Download() { IFileDownloader downloader = new FileDownloader(); downloader.Initialize(); using (var file = downloader.Download(new Uri("http://www.google.co.nz/"))) { Assert.IsNotNull(file); file.File.Refresh(); Assert.IsTrue(file.File.Length > 0); } }
public void Progress_event() { IEventAggregator aggregator = new EventAggregator(); IFileDownloader downloader = new FileDownloader(aggregator); downloader.Initialize(); var progressEvent = aggregator.GetEvent<UpdateProgressEvent>(); int progressEventTimes = 0; progressEvent.Subscribe(state => progressEventTimes++); using (var file = downloader.Download(new Uri("http://www.google.co.nz/"))) { Assert.IsNotNull(file); file.File.Refresh(); Assert.IsTrue(file.File.Length > 0); } Assert.IsTrue(progressEventTimes > 0); }
public void Exception_if_trying_to_download_without_calling_Initialize_first() { var aggregator = new Mock<IEventAggregator>(); var downloader = new FileDownloader(aggregator.Object); downloader.Download(new Uri("http://www.google.com/")); }