public async Task HandleWithPlaylistMessage_QueHasItemOfTypeArtist_CallsSubsonicServiceGetArtistAndAddsAllSongsFromAllAlbumsToThePlaylist() { MockLoadModel(); var addToPlaylistQue = new List <ISubsonicModel> { new ExpandedArtist { Id = 5 } }; var albums = new List <Common.Models.Subsonic.Album> { new Common.Models.Subsonic.Album(), new Common.Models.Subsonic.Album() }; var artist = new ExpandedArtist { Albums = albums }; var mockGetAlbumResult = new MockGetArtistResult { GetResultFunc = () => artist }; var callCount = 0; MockSubsonicService.GetArtist = albumId => { callCount++; albumId.Should().Be(5); return(mockGetAlbumResult); }; var getAlbumCallCount = 0; MockSubsonicService.GetAlbum = artistId => { getAlbumCallCount++; return(new MockGetAlbumResult { GetResultFunc = () => new Common.Models.Subsonic.Album { Songs = new List <Song> { new Song() } } }); }; await Task.Run(() => Subject.Handle(new PlaylistMessage { Queue = addToPlaylistQue })); callCount.Should().Be(1); getAlbumCallCount.Should().Be(2); MockEventAggregator.Messages.All(m => m.GetType() == typeof(AddItemsMessage)).Should().BeTrue(); MockEventAggregator.Messages.Count.Should().Be(2); }
AddToPlaylist_QueHasItemOfTypeArtist_CallsSubsonicServiceGetArtistAndAddsAllSongsFromAllAlbumsToThePlaylist() { MockLoadModel(); Subject.SelectedItems.Add(new MenuItemViewModel { Item = new ExpandedArtist { Id = 5 } }); Debug.WriteLine(Subject.EventAggregator); var albums = new List <Album> { new Album(), new Album() }; var artist = new ExpandedArtist { Albums = albums }; var mockGetAlbumResult = new MockGetArtistResult { GetResultFunc = () => artist }; var callCount = 0; _mockSubsonicService.GetArtist = albumId => { callCount++; albumId.Should().Be(5); return(mockGetAlbumResult); }; var getAlbumCallCount = 0; _mockSubsonicService.GetAlbum = artistId => { getAlbumCallCount++; return(new MockGetAlbumResult { GetResultFunc = () => new Album { Songs = new List <Song> { new Song() } } }); }; await Subject.AddToPlaylist(); callCount.Should().Be(1); getAlbumCallCount.Should().Be(2); MockEventAggregator.Messages.All(m => m.GetType() == typeof(AddItemsMessage)).Should().BeTrue(); MockEventAggregator.Messages.Count.Should().Be(2); }