1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-01-14 22:18:43 +00:00

ListPlaylist command implemeted + test.

This commit is contained in:
glucaci 2016-12-20 16:17:06 +01:00
parent 092240c22f
commit 982a013839
2 changed files with 33 additions and 0 deletions

View File

@ -21,6 +21,25 @@ namespace LibMpc
/// </summary> /// </summary>
public static class Stored public static class Stored
{ {
public class ListPlaylist : IMpcCommand<IEnumerable<IMpdFilePath>>
{
private readonly string _playlistName;
public ListPlaylist(string playlistName)
{
_playlistName = playlistName;
}
public string Value => string.Join(" ", "listplaylist", $"\"{_playlistName}\"");
public IEnumerable<IMpdFilePath> FormatResponse(IList<KeyValuePair<string, string>> response)
{
var results = response.Where(line => line.Key.Equals("file")).Select(line => new MpdFile(line.Value));
return results;
}
}
/// <summary> /// <summary>
/// Prints a list of the playlist directory. /// Prints a list of the playlist directory.
/// </summary> /// </summary>

View File

@ -8,6 +8,20 @@ namespace LibMpcTest
{ {
public partial class 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] [Fact]
public async Task ListPlaylistsTest() public async Task ListPlaylistsTest()
{ {