Exemple #1
0
        public void TranscodesOtherFormats()
        {
            var fakeFiles = new string[] { "test.m4a" };
            var fakeMusicInfo = new MusicInfo()
            {
                Album = "Test",
                Artist = "Test2"
            };

            var transcodedFile = "test.mp3";
            var fakeMusicInfoReader = new FakeMusicInfoReader(fakeMusicInfo);
            var importFolderInteractor = new FakeFolderInteractor(fakeFiles);
            var fakeTranscoder = new FakeTranscoder();
            var library = new MemoryLibraryRepository();
            library.ClearLibrary();
            var importFolderWatcher = new ImportFolderWatcher(importFolderInteractor, fakeMusicInfoReader, library, fakeTranscoder);

            importFolderWatcher.ProcessFiles();

            var expectedLibraryPath = @"c:\temp\" + fakeMusicInfo.Artist + "\\" + fakeMusicInfo.Album + "\\" + transcodedFile;

            Assert.AreEqual(1, importFolderInteractor.MovedFiles.Count(), "There must one moved file");
            Assert.AreEqual(transcodedFile, importFolderInteractor.MovedFiles[0].SourceFile, "The file to move must be correct.");
            Assert.AreEqual(expectedLibraryPath, importFolderInteractor.MovedFiles[0].DestinationFile, "The file must be moved to the correct folder.");
            Assert.IsTrue(importFolderInteractor.DeletedFiles.Contains(fakeFiles[0]), "The original file must be deleted.");
            Assert.IsTrue(importFolderInteractor.DeletedFiles.Contains(expectedLibraryPath), "The library path must be deleted.");
            Assert.AreEqual(2, importFolderInteractor.DeletedFiles.Count(), "There must be 2 attempted file deletes.");
        }
Exemple #2
0
        public void UnknownFileType()
        {
            var fakeFiles = new string[] { "readme.txt" };
            var importFolderInteractor = new FakeFolderInteractor(fakeFiles);
            var importFolderWatcher = new ImportFolderWatcher(importFolderInteractor, null, null,null);

            importFolderWatcher.ProcessFiles();

            Assert.AreEqual(0, importFolderInteractor.MovedFiles.Count(), "There must no moved files.");
        }
Exemple #3
0
        public void SanitizeFolderNames()
        {
            var importFolder = new ImportFolderWatcher(new MemoryLibraryRepository());
            var badFolderName = "[]/\\&~?*|<>\";:+";
            var expectedName = "               ";

            var result = importFolder.SanitizeFolderName(badFolderName);

            Assert.AreEqual(expectedName, result, "The folder name must replace the bad characters with spaces.");
        }
Exemple #4
0
        public void OneMp3file_NoInfo()
        {
            var fakeFiles = new string[] { "one.mp3" };
            var fakeMusicInfo = new MusicInfo()
            {
                Album = "",
                Artist = ""
            };

            var fakeMusicInfoReader = new FakeMusicInfoReader(fakeMusicInfo);
            var importFolderInteractor = new FakeFolderInteractor(fakeFiles);
            var importFolderWatcher = new ImportFolderWatcher(importFolderInteractor, fakeMusicInfoReader, new MemoryLibraryRepository(), null);

            importFolderWatcher.ProcessFiles();

            var expectedLibraryPath = @"c:\temp\Unknown Artist\Unknown Album\" + fakeFiles[0];

            Assert.AreEqual(1, importFolderInteractor.MovedFiles.Count(), "There must one moved file");
            Assert.AreEqual(fakeFiles[0], importFolderInteractor.MovedFiles[0].SourceFile, "The file to move must be correct.");
            Assert.AreEqual(expectedLibraryPath, importFolderInteractor.MovedFiles[0].DestinationFile, "The file must be moved to the correct folder.");
        }
Exemple #5
0
        public void OneMp3file()
        {
            var fakeFiles = new string[] { "one.mp3" };
            var fakeMusicInfo = new MusicInfo() {
                Album = "onealbum",
                Artist = "oneartist"
            };

            var fakeMusicInfoReader = new FakeMusicInfoReader(fakeMusicInfo);
            var importFolderInteractor = new FakeFolderInteractor(fakeFiles);
            var library = new MemoryLibraryRepository();
            library.ClearLibrary();
            var importFolderWatcher = new ImportFolderWatcher(importFolderInteractor, fakeMusicInfoReader, library, null);

            importFolderWatcher.ProcessFiles();

            var expectedLibraryPath = @"c:\temp\" + fakeMusicInfo.Artist + "\\" + fakeMusicInfo.Album + "\\" + fakeFiles[0];

            Assert.AreEqual(1, importFolderInteractor.MovedFiles.Count(), "There must one moved file");
            Assert.AreEqual(fakeFiles[0], importFolderInteractor.MovedFiles[0].SourceFile, "The file to move must be correct.");
            Assert.AreEqual(expectedLibraryPath, importFolderInteractor.MovedFiles[0].DestinationFile, "The file must be moved to the correct folder.");

            var libraryFiles = library.GetAllMusic();

            Assert.AreEqual(1, libraryFiles.Count(), "There must be one file in the library.");
            Assert.AreEqual(fakeMusicInfo.Artist, libraryFiles[0].Artist, "The artist added to the library must be correct.");
            Assert.AreEqual(expectedLibraryPath, libraryFiles[0].FullPath, "The full path of the file in the library must be correct.");
        }
Exemple #6
0
        public void NoFiles()
        {
            var importFolderInteractor = new FakeFolderInteractor(new string[0]);
            var importFolderWatcher = new ImportFolderWatcher(importFolderInteractor, null, null, null);

            importFolderWatcher.ProcessFiles();

            Assert.AreEqual(0, importFolderInteractor.MovedFiles.Count(), "There must not be any moved files");
        }
Exemple #7
0
        private void StartPlayer()
        {
            try
            {
                var playlistManager = GetPlaylistManager();
                var messagingWatcher = new MessagingPlaylistWatcher();
                var playlist = new Playlist(new IPlaylistWatcher[] { playlistManager, messagingWatcher });
                var dummyAudio = new NAudioInteractor();
                var library = new MongoLibraryRepository(null);
                _folderWatcher = new ImportFolderWatcher(library);

                if (ConfigurationManager.AppSettings["ResetLibraryForTesting"]=="true")
                    InsertTestSongs(library);

                var player = new Player(playlist, dummyAudio, library);
                _pubnub = new PubnubMessaging(player, true);

                messagingWatcher.AssignMessaging(_pubnub);
                messagingWatcher.AttachToPlaylist(playlist, library);
                playlistManager.AttachToPlaylist(playlist, library);

                _pubnub.StartListening();

                library.Messaging = _pubnub;

                _folderWatcher.Start();

                if (ConfigurationManager.AppSettings["AutoStartPlaying"]=="true")
                    player.Play();

                _pubnub.SendNowPlaying(playlist[0]);
            }
            catch (Exception exc)
            {
                Log.Debug(exc.ToString());
            }
        }