diff --git a/LibMpc/Commands/Commands.Playlists.cs b/LibMpc/Commands/Commands.Playlists.cs index f4356f5..0d5bb67 100644 --- a/LibMpc/Commands/Commands.Playlists.cs +++ b/LibMpc/Commands/Commands.Playlists.cs @@ -21,6 +21,25 @@ namespace LibMpc /// public static class Stored { + public class ListPlaylist : IMpcCommand> + { + private readonly string _playlistName; + + public ListPlaylist(string playlistName) + { + _playlistName = playlistName; + } + + public string Value => string.Join(" ", "listplaylist", $"\"{_playlistName}\""); + + public IEnumerable FormatResponse(IList> response) + { + var results = response.Where(line => line.Key.Equals("file")).Select(line => new MpdFile(line.Value)); + + return results; + } + } + /// /// Prints a list of the playlist directory. /// diff --git a/LibMpcTest/Tests/PlaylistsCommandsTest.cs b/LibMpcTest/Tests/PlaylistsCommandsTest.cs index 7f95242..41a0a26 100644 --- a/LibMpcTest/Tests/PlaylistsCommandsTest.cs +++ b/LibMpcTest/Tests/PlaylistsCommandsTest.cs @@ -8,6 +8,20 @@ namespace LibMpcTest { public partial class LibMpcTest { + [Theory] + [InlineData("Playlist One", 5)] + [InlineData("Playlist Two", 3)] + [InlineData("_My Playlist", 5)] + public async Task ListPlaylistTest(string playlistName, int numberOfFiles) + { + var response = await Mpc.SendAsync(new Commands.Playlists.Stored.ListPlaylist(playlistName)); + + TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:"); + TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented)); + + Assert.True(response.Response.Body.Count().Equals(numberOfFiles)); + } + [Fact] public async Task ListPlaylistsTest() {