コード例 #1
0
 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);
     }
 }
コード例 #2
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);
        }
コード例 #3
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/"));
 }