public void Initialize_sets_flag()
        {
            var aggregator = new Mock<IEventAggregator>();
            var downloader = new FileDownloader(aggregator.Object);

            Assert.IsFalse(downloader.IsInitialized);
            downloader.Initialize();
            Assert.IsTrue(downloader.IsInitialized);
        }
        public void Initialize_gets_Progress_event()
        {
            var aggregator = new Mock<IEventAggregator>();
            var downloader = new FileDownloader(aggregator.Object);

            downloader.Initialize();

            aggregator.Verify(eventAggregator => eventAggregator.GetEvent<UpdateProgressEvent>());
            Assert.AreEqual(aggregator.Object, downloader.EventAggregator);
        }
 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/"));
 }
        public void Creates_default_EventAggregator()
        {
            var downloader = new FileDownloader();

            Assert.IsNotNull(downloader.EventAggregator);
        }
 public void Constructor_takes_EventAggregator()
 {
     var aggregator = new Mock<IEventAggregator>();
     var downloader = new FileDownloader(aggregator.Object);
     Assert.AreEqual(aggregator.Object, downloader.EventAggregator);
 }