AddToPlaylist_SelectedItemsHasItemOfTypeAlbum_CallsSubsonicServiceGetAlbumAndAdsAllItsSongsToThePlaylist()
        {
            MockLoadModel();
            Subject.SelectedItems.Add(new MenuItemViewModel {
                Item = new Album {
                    Id = 5
                }
            });
            var songs = new List <Song> {
                new Song(), new Song()
            };
            var album = new Album {
                Songs = songs
            };
            var mockGetAlbumResult = new MockGetAlbumResult {
                GetResultFunc = () => album
            };
            var callCount = 0;

            _mockSubsonicService.GetAlbum = albumId =>
            {
                callCount++;
                albumId.Should().Be(5);
                return(mockGetAlbumResult);
            };

            await Subject.AddToPlaylist();

            callCount.Should().Be(1);
            MockEventAggregator.Messages.All(m => m.GetType() == typeof(AddItemsMessage)).Should().BeTrue();
            MockEventAggregator.Messages.Count.Should().Be(2);
        }
Ejemplo n.º 2
0
        public async Task HandleWithPlaylistMessage_QueHasItemOfTypeAlbum_CallsSubsonicServiceGetAlbumAndAdsAllItsSongsToThePlaylist()
        {
            MockLoadModel();
            var subsonicModels = new List <ISubsonicModel> {
                new Common.Models.Subsonic.Album {
                    Id = 5
                }
            };
            var songs = new List <Song> {
                new Song(), new Song()
            };
            var album = new Common.Models.Subsonic.Album {
                Songs = songs
            };
            var mockGetAlbumResult = new MockGetAlbumResult {
                GetResultFunc = () => album
            };
            var callCount = 0;

            MockSubsonicService.GetAlbum = albumId =>
            {
                callCount++;
                albumId.Should().Be(5);
                return(mockGetAlbumResult);
            };

            await Task.Run(() => Subject.Handle(new PlaylistMessage {
                Queue = subsonicModels
            }));

            callCount.Should().Be(1);
            MockEventAggregator.Messages.All(m => m.GetType() == typeof(AddItemsMessage)).Should().BeTrue();
            MockEventAggregator.Messages.Count.Should().Be(2);
        }