Exemple #1
0
 public DownloadManager(IDownloadDirectory aDownloadDirectory, IUrlFetcher aUrlFetcher)
 {
     iDownloadDirectory = aDownloadDirectory;
     iMessageQueue = new Channel<Action<IDownloadThread>>(5);
     var urlPoller = new DefaultUrlPoller();
     var pollManager = new PollManager(urlPoller);
     iDownloader = new Downloader(iDownloadDirectory, iMessageQueue, pollManager, aUrlFetcher);
     iDownloadThread = new CommunicatorThread(iDownloader.Run, "DownloadManager");
     iDownloadThread.Start();
 }
Exemple #2
0
 public void SetUp()
 {
     iOnSelectActions = new Queue<Action<int,ChannelAction[]>>();
     iAbandoned = false;
     iDirectoryMock = new Mock<IDownloadDirectory>();
     iMessageQueue = new Channel<Action<IDownloadThread>>(10);
     iCommunicator = new Mock<IThreadCommunicator>();
     iPollManager = new Mock<IPollManager>();
     iUrlFetcher = new Mock<IUrlFetcher>();
     iDownloader = new Downloader(iDirectoryMock.Object, iMessageQueue, iPollManager.Object, iUrlFetcher.Object);
     iCommunicator.Setup(x=>x.Abandoned).Returns(()=>iAbandoned);
     iCommunicator.Setup(x=>x.CheckAbandoned()).Returns(()=>iAbandoned);
     iCommunicator.Setup(x=>x.Select(It.IsAny<ChannelAction[]>()))
         .Callback((ChannelAction[] aActions)=>OnSelect(-1, aActions));
     iCommunicator.Setup(x=>x.SelectWithTimeout(It.IsAny<int>(), It.IsAny<ChannelAction[]>()))
         .Callback((int aTimeout, ChannelAction[] aActions) => OnSelect(aTimeout, aActions));
 }
Exemple #3
0
 public DownloadListener(Downloader aParent, string aUri, string aLocalPath, Action<string, DateTime> aCompletedCallback, Action aFailedCallback)
 {
     iParent = aParent;
     iUri = aUri;
     iLocalPath = aLocalPath;
     CompletedCallback = aCompletedCallback;
     FailedCallback = aFailedCallback;
 }