public void DownloadWantedEpisodes()
        {
            var service = new Mock <ITvService>();

            service.Setup(c => c.GetWantedEpisodes()).Returns(new List <TvEpisode> {
                new TvEpisode()
                {
                    SeriesName = "SomeSeries", Season = 1, EpisodeNumber = 1
                }
            });

            var torrent = new Torrent()
            {
                DownloadUrl = "DownloadUrl",
                Name        = "Torrent"
            };

            var searchProvider = new Mock <ISearchProvider>();

            searchProvider.Setup(sp => sp.GetTorrent(It.IsAny <string>())).Returns(torrent);

            var webRequester     = new Mock <IWebClient>();
            var analyticsService = new Mock <IAnalyticsService>();

            var downloader = new EpisodeDownloader(service.Object, searchProvider.Object, webRequester.Object, new TorrentSearchSettings()
            {
                TorrentWatchFolder = "WatchFolder\\"
            }, analyticsService.Object);

            downloader.DownloadWantedEpisodes().Wait();

            webRequester.Verify(wr => wr.DownloadFileAsync(torrent.DownloadUrl, "WatchFolder\\Torrent.torrent", null), Times.Once);
            service.Verify(s => s.AddOrUpdate(It.IsAny <TvEpisode>()), Times.AtLeastOnce);
            service.Verify(s => s.SaveChanges(), Times.Once);
        }
        protected override void GivenThat()
        {
            base.GivenThat();

            _webClientFactory      = GenerateMock <IWebClientFactory>();
            _webClient             = GenerateMock <IWebClient>();
            _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>();
            _directoryInfo         = GenerateMock <IDirectoryInfo>();
            _fileUtilities         = GenerateMock <IFileUtilities>();
            _stateProvider         = GenerateMock <IStateProvider>();
            _counterFactory        = GenerateMock <ICounterFactory>();
            _averageCounterTime    = GenerateMock <IAverageCounter>();
            _averageCounterSize    = GenerateMock <IAverageCounter>();
            _state           = GenerateMock <IState>();
            _commandExecuter = GenerateMock <ICommandExecuter>();

            _syncItem  = new SyncItem();
            _exception = null;

            SetupData();
            SetupStubs();

            _downloader = new EpisodeDownloader(_webClientFactory, _directoryInfoProvider, _fileUtilities, _stateProvider, _counterFactory, _commandExecuter);
            _downloader.StatusUpdate   += new EventHandler <StatusUpdateEventArgs>(DownloaderStatusUpdate);
            _downloader.ProgressUpdate += new EventHandler <ProgressEventArgs>(DownloaderProgressUpdate);
        }
        public void BuildEpisodeSearchQuery()
        {
            var service = new Mock<ITvService>();
            var searchProvider = new Mock<ISearchProvider>();
            var webRequester = new Mock<IWebClient>();
            var analyticsService = new Mock<IAnalyticsService>();

            var downloader = new EpisodeDownloader(service.Object, searchProvider.Object, webRequester.Object, new TorrentSearchSettings() { TorrentWatchFolder = "WatchFolder\\" }, analyticsService.Object);
            var query = downloader.BuildSearchQuery(new TvEpisode() { SeriesName = "Some Series (2015)", Season = 1, EpisodeNumber = 1 } );

            Assert.That(query, Is.EqualTo("some series 2015 s01e01 720"));
        }
        public void BuildEpisodeSearchQuery()
        {
            var service          = new Mock <ITvService>();
            var searchProvider   = new Mock <ISearchProvider>();
            var webRequester     = new Mock <IWebClient>();
            var analyticsService = new Mock <IAnalyticsService>();

            var downloader = new EpisodeDownloader(service.Object, searchProvider.Object, webRequester.Object, new TorrentSearchSettings()
            {
                TorrentWatchFolder = "WatchFolder\\"
            }, analyticsService.Object);
            var query = downloader.BuildSearchQuery(new TvEpisode()
            {
                SeriesName = "Some Series (2015)", Season = 1, EpisodeNumber = 1
            });

            Assert.That(query, Is.EqualTo("some series 2015 s01e01 720"));
        }
        public void DownloadWantedEpisodes()
        {
            var service = new Mock<ITvService>();
            service.Setup(c => c.GetWantedEpisodes()).Returns(new List<TvEpisode> { new TvEpisode() { SeriesName = "SomeSeries", Season = 1, EpisodeNumber = 1 } });

            var torrent = new Torrent()
            {
                DownloadUrl = "DownloadUrl",
                Name = "Torrent"
            };

            var searchProvider = new Mock<ISearchProvider>();
            searchProvider.Setup(sp => sp.GetTorrent(It.IsAny<string>())).Returns(torrent);

            var webRequester = new Mock<IWebClient>();
            var analyticsService = new Mock<IAnalyticsService>();

            var downloader = new EpisodeDownloader(service.Object, searchProvider.Object, webRequester.Object, new TorrentSearchSettings() { TorrentWatchFolder = "WatchFolder\\" }, analyticsService.Object);
            downloader.DownloadWantedEpisodes().Wait();

            webRequester.Verify(wr => wr.DownloadFileAsync(torrent.DownloadUrl, "WatchFolder\\Torrent.torrent", null), Times.Once);
            service.Verify(s => s.AddOrUpdate(It.IsAny<TvEpisode>()), Times.AtLeastOnce);
            service.Verify(s => s.SaveChanges(), Times.Once);
        }
示例#6
0
 protected override void When()
 {
     _downloader = new EpisodeDownloader(_webClientFactory, _directoryInfoProvider, _fileUtilities, _stateProvider, _counterFactory, _commandExecuter);
 }