public void SearchSongs() { const string filter = "filter"; ObservableCollection<Song> expectedSongs = new ObservableCollection<Song>(); SongRepository.Setup(r => r.GetByFilter(filter, true, true, true)).Returns(expectedSongs); MusicService service = new MusicService(SongRepository.Object, MediaFileRepository.Object); IList<Song> findMusics = service.SearchSongs(filter, true, true, true); SongRepository.Verify(r => r.GetByFilter(filter, true, true, true), Times.Once()); Assert.AreEqual(expectedSongs, findMusics); }
public void SearchSongsAndReturnAllSongsIfFilterIsEmpty() { ObservableCollection<Song> expectedSongs = new ObservableCollection<Song>(); expectedSongs.Add(Create.Song()); SongRepository.Setup(r => r.GetByFilter(It.IsAny<string>(), true, true, true)).Returns(expectedSongs); MusicService service = new MusicService(SongRepository.Object, MediaFileRepository.Object); IList<Song> findMusics = service.SearchSongs(string.Empty, true, true, true); SongRepository.Verify(r => r.GetByFilter(It.IsAny<string>(), true, true, true), Times.Once()); Assert.AreEqual(expectedSongs, findMusics); Assert.AreEqual(1, findMusics.Count); }
public void SearchOnlyOnTitleAndArtist() { MusicService service = new MusicService(SongRepository.Object, MediaFileRepository.Object); IList<Song> findMusics = service.SearchSongs(string.Empty, true, true, false); SongRepository.Verify(r => r.GetByFilter(It.IsAny<string>(), true, true, false), Times.Once()); }