public void PlayerCanBeGivenANewPlaylist() { var library = new MemoryLibraryRepository(); var playlist = new Playlist(); var dummyAudio = new DummyAudioInteractor(); var player = new Player(playlist, dummyAudio, null); var song = "song1"; library.ClearLibrary(); library.AddMusicToLibrary(new MusicInfo[] { new MusicInfo() { FullPath = song } }); playlist.AddRange(library.GetAllMusic()); player.Play(); Assert.AreEqual(song, playlist.CurrentSong.FullPath, "The last song played must be the only one in the library."); var song2 = "song 2"; library.ClearLibrary(); library.AddMusicToLibrary(new MusicInfo[] { new MusicInfo() { FullPath = song2 } }); playlist.AddRange(library.GetAllMusic()); player.PlayCount = 0; player.Play(); Assert.AreEqual(song, playlist.PreviousSong.FullPath, "The previous played must be new song in the library."); Assert.AreEqual(song2, playlist.CurrentSong.FullPath, "The current played must be new song in the library."); }
public void MemoryLibraryShouldBeSingleton() { var music = new MusicInfo() { Album = "Test Album", Artist = "Test Artist", FullPath = "Test Path", Title = "Test Title" }; var repository = new MemoryLibraryRepository(); repository.ClearLibrary(); repository.AddMusicToLibrary(new MusicInfo[] { music }); List<MusicInfo> result = repository.GetAllMusic(); Assert.IsNotNull(result, "The result must not be null."); Assert.AreEqual(1, result.Count, "There must only be one song."); var repository2 = new MemoryLibraryRepository(); music.FullPath += 2; repository2.AddMusicToLibrary(new MusicInfo[] { music }); result = repository2.GetAllMusic(); Assert.AreEqual(2, result.Count, "There must two songs."); }
public void AddMusicToLibrary() { var music = new MusicInfo() { Album = "Test Album", Artist = "Test Artist", FullPath = "Test Path", Title = "Test Title" }; var pubnubStub = MockRepository.GenerateStub<IRealTimeMessaging>(); pubnubStub.Stub(X => X.SendSongsAdded(null)); var repository = new MemoryLibraryRepository(pubnubStub); repository.ClearLibrary(); repository.AddMusicToLibrary(new MusicInfo[] {music}); List<MusicInfo> result = repository.GetAllMusic(); Assert.IsNotNull(result, "The result must not be null."); Assert.AreEqual(1, result.Count, "There must only be one song."); Assert.AreEqual(music.Album, result[0].Album, "The result must be for the correct album."); Assert.AreEqual(music.Artist, result[0].Artist, "The artist must be correct."); Assert.AreEqual(music.Title, result[0].Title, "The title must be correct."); Assert.AreEqual(music.FullPath, result[0].FullPath, "The full path must be correct."); pubnubStub.AssertWasCalled(X => X.SendSongsAdded(null), Y => Y.IgnoreArguments()); }
public void Loop() { var song1 = "song1"; var song2 = "song2"; var library = new MemoryLibraryRepository(); library.ClearLibrary(); library.AddMusicToLibrary( new MusicInfo[] { new MusicInfo() { FullPath = song1 }, new MusicInfo() { FullPath = song2 } }); var loopingWatcher = new LoopingPlaylistWatcher(); var playlist = new Playlist(loopingWatcher); var dummyAudio = new DummyAudioInteractor(); var player = new Player(playlist, dummyAudio, library); loopingWatcher.AttachToPlaylist(playlist, library); playlist.AddRange(library.GetAllMusic()); player.MaxPlayCount = 3; player.Play(); Assert.AreEqual(3, dummyAudio.PlayHistory.Count, "There must be three songs in the history."); Assert.AreEqual(song1, dummyAudio.PlayHistory[0], "The first song must play first."); Assert.AreEqual(song2, dummyAudio.PlayHistory[1], "The second song must play second."); Assert.AreEqual(song1, dummyAudio.PlayHistory[2], "The first song must play third."); Assert.AreEqual(2, playlist.RemainingSongs, "After playing three songs there must still be 2 songs in the playlist."); }
public void AddFolderToLibrary() { var testDirectory = @"..\..\..\TestFiles"; var title = "one"; var repository = new MemoryLibraryRepository(); repository.ClearLibrary(); repository.AddDirectoryToLibrary(testDirectory); List<MusicInfo> result = repository.GetAllMusic(); Assert.IsNotNull(result, "The result must not be null."); Assert.Greater(result.Count, 0, "There must many songs."); Assert.AreEqual(title, result[0].Title, "The title must be correct."); }
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."); }