public void Should_ReturnMinusOne_When_CalledAddNewSongWithNull() { //Arrange Song song = null; var mock = new Mock <ISongService>(); mock.Setup(m => m.AddItem(song)); mock.Setup(m => m.UpdateFileWithSongs(song)); var manager = new SongManager(new MenuView(), mock.Object); //Act var result = manager.AddNewSong(song); //Assert result.Should().NotBe(null); result.Should().Be(-1); }
public void Should_AddSong_When_CalledAddNewSong() { //Arrange Song song = new Song(1, "The Weeknd", "The Hills", GenreName.Pop, 2015, 1, ""); var mock = new Mock <ISongService>(); mock.Setup(m => m.AddItem(song)); mock.Setup(m => m.UpdateFileWithSongs(song)); var manager = new SongManager(new MenuView(), mock.Object); //Act var result = manager.AddNewSong(song); //Assert result.Should().NotBe(null); result.Should().NotBe(-1); result.Should().Be(song.Id); }
static void Main(string[] args) { MenuView menuView = new MenuView(); ISongService songService = new SongService(); IPlaylistService playlistService = new PlaylistService(); SongManager songManager = new SongManager(menuView, songService); PlaylistManager playlistManager = new PlaylistManager(menuView, songService, playlistService); bool running = true; while (running) { Console.Clear(); menuView.ShowMainMenu(); var operation = Console.ReadKey(); Console.WriteLine(); bool again = true; switch (operation.KeyChar) { case '1': Console.Clear(); var newSong = songManager.CreateNewSong(); int newSongId = songManager.AddNewSong(newSong); if (newSongId != -1) { Console.ReadKey(); } break; case '2': do { Console.Clear(); int choice = songManager.Recommend(); again = songManager.RecommendationSwitcher(choice); } while (again); break; case '3': do { Console.Clear(); string title = songManager.ChooseSongToBeLiked(); int songId = songManager.LikeChosenSong(title); again = songManager.SuccessfulOrFailedLikeInfo(songId); }while(again); break; case '4': do { Console.Clear(); string title = songManager.ChooseSongToShowDetails(); var song = songManager.SearchSongToShowDetails(title); again = songManager.ShowDetails(song); } while (again); break; case '5': do { Console.Clear(); int choice = playlistManager.ChooseToCreateOrAddPlaylist(); again = playlistManager.CreateNewOrAddSwitcher(choice); } while (again); break; case '6': int playlistId; do { Console.Clear(); playlistId = playlistManager.ChoosePlaylistToShow(); playlistManager.ShowPlaylist(playlistId); } while (playlistId != -1); break; case '7': running = false; break; default: Console.WriteLine("Such action doesn't exist. Press any key to try again..."); Console.ReadKey(); break; } } }