Ejemplo n.º 1
0
        protected override void GivenThat()
        {
            base.GivenThat();

            _controlFile = TestControlFileFactory.CreateControlFile();
            _feedInfo    = new FeedInfo(_controlFile);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// generate a playlist
        /// </summary>
        /// <param name="control">control file to use to find the destinationRoot, and playlist format</param>
        /// <param name="copyToDestination">true to copy the playlist to the destination, false to write it locally</param>
        public void GeneratePlaylist(IReadOnlyControlFile control, bool copyToDestination)
        {
            var allDestFiles = control.GetPodcasts().SelectMany(
                podcast => FileFinder.GetFiles(Path.Combine(control.GetDestinationRoot(), podcast.Folder), podcast.Pattern.Value));

            IPlaylist p = PlaylistFactory.CreatePlaylist(control.GetPlaylistFormat(), control.GetPlaylistFileName());

            string pathSeparator = PathUtilities.GetPathSeparator().ToString();

            foreach (IFileInfo thisFile in allDestFiles)
            {
                string thisRelativeFile = thisFile.FullName;
                string absRoot          = PathUtilities.GetFullPath(control.GetDestinationRoot());
                if (thisRelativeFile.StartsWith(absRoot, StringComparison.Ordinal))
                {
                    thisRelativeFile = thisRelativeFile.Substring(absRoot.Length);
                }
                thisRelativeFile = thisRelativeFile.Replace(pathSeparator, control.GetPlaylistPathSeparator());
                p.AddTrack("." + thisRelativeFile);
            }

            var tempFile = PathUtilities.GetTempFileName();

            OnStatusUpdate(string.Format(CultureInfo.InvariantCulture, "Generating Playlist with {0} items", p.NumberOfTracks));

            p.SaveFile(tempFile);

            var destPlaylist = copyToDestination
                                   ? Path.Combine(control.GetDestinationRoot(), control.GetPlaylistFileName())
                                   : control.GetPlaylistFileName();

            OnStatusUpdate(string.Format(CultureInfo.InvariantCulture, "Writing playlist to {0}", destPlaylist));

            FileUtilities.FileCopy(tempFile, destPlaylist, true);
        }
        protected override void GivenThat()
        {
            base.GivenThat();

            _controlFile = TestControlFileFactory.CreateControlFile();

            _stateProvider         = GenerateMock <IStateProvider>();
            _state                 = GenerateMock <IState>();
            _timeProvider          = GenerateMock <ITimeProvider>();
            _webClientFactory      = GenerateMock <IWebClientFactory>();
            _webClient             = GenerateMock <IWebClient>();
            _feedFactory           = GenerateMock <IPodcastFeedFactory>();
            _fileUtilities         = GenerateMock <IFileUtilities>();
            _podcastFeed           = GenerateMock <IPodcastFeed>();
            _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>();
            _directoryInfo         = GenerateMock <IDirectoryInfo>();
            _commandGenerator      = GenerateMock <ICommandGenerator>();
            _pathUtilities         = GenerateMock <IPathUtilities>();

            SetupData();
            SetupStubs();

            _episodeFinder = new EpisodeFinder(_fileUtilities, _feedFactory, _webClientFactory, _timeProvider, _stateProvider, _directoryInfoProvider, _commandGenerator, _pathUtilities);
            _episodeFinder.StatusUpdate += new EventHandler <StatusUpdateEventArgs>(EpisodeFinderStatusUpdate);
            _latestUpdate = null;
        }
Ejemplo n.º 4
0
        protected override void GivenThat()
        {
            base.GivenThat();

            _controlFile = TestControlFileFactory.CreateControlFile();

            PodcastFactory = new PodcastFactory();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// generate a playlist for the files in the destination folder
 /// </summary>
 /// <param name="control">control file to use to find the destinationRoot, and playlist format</param>
 /// <param name="rootFolder">root folder to find episodes</param>
 /// <param name="copyToDestination">true to copy the playlist to the destination, false to write it locally</param>
 /// <param name="statusUpdate">the update mechanism for the generation - can be null</param>
 public void GeneratePlaylist(IReadOnlyControlFile control, string rootFolder, bool copyToDestination, EventHandler <StatusUpdateEventArgs> statusUpdate)
 {
     if (statusUpdate != null)
     {
         StatusUpdate += statusUpdate;
     }
     GeneratePlaylist(control, rootFolder, copyToDestination);
 }
        protected override void GivenThat()
        {
            base.GivenThat();

            _controlFile = TestControlFileFactory.CreateControlFile();

            _environmentInformationProvider = GenerateMock <IEnvironmentInformationProvider>();
            _directoryInfo = GenerateMock <IDirectoryInfo>();

            SetupData();
            SetupStubs();

            _generator = new CommandGenerator(_environmentInformationProvider);
        }
        protected override void GivenThat()
        {
            base.GivenThat();

            ControlFile = GenerateMock <IReadOnlyControlFile>();

            Podcast = new PodcastInfo(ControlFile)
            {
                Feed = new FeedInfo(ControlFile)
            };

            PodcastViewModel = new PodcastViewModel(Podcast);

            ViewModel = new EditPodcastViewModel(PodcastViewModel);
        }
        protected override void GivenThat()
        {
            base.GivenThat();

            _controlFile = TestControlFileFactory.CreateControlFile();

            _timeProvider          = GenerateMock <ITimeProvider>();
            _directoryInfoProvider = GenerateMock <IDirectoryInfoProvider>();
            _directoryInfo         = GenerateMock <IDirectoryInfo>();
            _fileUtilities         = GenerateMock <IFileUtilities>();

            SetupData();
            SetupStubs();

            _episodePurger = new EpisodePurger(_timeProvider, _directoryInfoProvider, _fileUtilities);
        }
        protected override void GivenThat()
        {
            base.GivenThat();

            _controlFile = TestControlFileFactory.CreateControlFile();
            _podcastInfo = new PodcastInfo(_controlFile);

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.OmitXmlDeclaration = true;
            settings.ConformanceLevel   = ConformanceLevel.Fragment;
            settings.CloseOutput        = false;
            settings.Encoding           = Encoding.UTF8;

            _memoryStream = new MemoryStream();
            _xmlWriter    = XmlWriter.Create(_memoryStream, settings);
        }
Ejemplo n.º 10
0
        protected override void GivenThat()
        {
            base.GivenThat();

            ControlFile = GenerateMock <IReadOnlyControlFile>();

            var podcast = new PodcastInfo(ControlFile)
            {
                Folder = "Original Name",
                Feed   = new FeedInfo(ControlFile)
                {
                    Address = new Uri("http://www.originaladdress.com/ppp.xml")
                }
            };

            ViewModel = new PodcastViewModel(podcast);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// synchronise podcast media files
        /// </summary>
        /// <param name="controlFile">control file to use to control the process</param>
        /// <param name="whatIf">true to generate the status messages but not to actually perform the file copy / deletes</param>
        public void Synchronize(IReadOnlyControlFile controlFile, bool whatIf)
        {
            var filesToCopy = new List <FileSyncItem>();

            foreach (PodcastInfo podcast in controlFile.GetPodcasts())
            {
                string podcastSourcePath      = Path.Combine(controlFile.GetSourceRoot(), podcast.Folder);
                string podcastDestinationPath = Path.Combine(controlFile.GetDestinationRoot(), podcast.Folder);

                IList <IFileInfo> podcastSourceFiles = FileFinder.GetFiles(
                    podcastSourcePath,
                    podcast.Pattern.Value,
                    podcast.MaximumNumberOfFiles.Value,
                    podcast.SortField.Value,
                    podcast.AscendingSort.Value);

                FileRemover.RemoveUnwantedFiles(podcastSourceFiles, podcastDestinationPath, podcast.Pattern.Value, whatIf);

                IEnumerable <FileSyncItem> podcastSyncItems = podcastSourceFiles.Select(p => new FileSyncItem {
                    Source = p
                });

                filesToCopy.AddRange(podcastSyncItems);
            }

            FileCopier.CopyFilesToTarget(
                filesToCopy,
                controlFile.GetSourceRoot(),
                controlFile.GetDestinationRoot(),
                controlFile.GetFreeSpaceToLeaveOnDestination(),
                whatIf);

            foreach (PodcastInfo podcast in controlFile.GetPodcasts())
            {
                if (podcast.DeleteEmptyFolder.Value)
                {
                    string podcastDestinationPath = Path.Combine(controlFile.GetDestinationRoot(), podcast.Folder);
                    FolderRemover.RemoveFolderIfEmpty(podcastDestinationPath, whatIf);
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// generate a playlist for the files in the destination folder
 /// </summary>
 /// <param name="control">control file to use to find the destinationRoot, and playlist format</param>
 /// <param name="copyToDestination">true to copy the playlist to the destination, false to write it locally</param>
 public void GeneratePlaylist(IReadOnlyControlFile control, bool copyToDestination)
 {
     GeneratePlaylist(control, control.GetDestinationRoot(), copyToDestination);
 }