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

UrlHandlers command implemented and tested. Print MPD version in test.

This commit is contained in:
glucaci 2016-12-20 11:31:48 +01:00
parent 4cb95df50f
commit ef57b0a76b
4 changed files with 25 additions and 2 deletions

View File

@ -41,7 +41,18 @@ namespace LibMpc
} }
} }
// TODO: urlhandlers public class UrlHandlers : IMpcCommand<IEnumerable<string>>
{
public string Value => "urlhandlers";
public IEnumerable<string> FormatResponse(IList<KeyValuePair<string, string>> response)
{
var result = response.Where(item => item.Key.Equals("handler")).Select(item => item.Value);
return result;
}
}
// TODO: decoders // TODO: decoders
} }
} }

View File

@ -24,6 +24,7 @@ namespace LibMpc
} }
public bool IsConnected => _connection?.IsConnected ?? false; public bool IsConnected => _connection?.IsConnected ?? false;
public string Version => _connection?.Version ?? "Unknown";
public async Task<bool> ConnectAsync() public async Task<bool> ConnectAsync()
{ {

View File

@ -12,7 +12,7 @@ namespace LibMpcTest
Client = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600)); Client = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
var connected = Task.Run(async () => await Client.ConnectAsync()).Result; var connected = Task.Run(async () => await Client.ConnectAsync()).Result;
TestOutput.WriteLine($"Connected to MPD : {connected}"); TestOutput.WriteLine($"Connected to MPD : {connected}; Version: {Client.Version}");
} }
public Mpc Client { get; } public Mpc Client { get; }

View File

@ -31,5 +31,16 @@ namespace LibMpcTest
Assert.True(response.Response.Body.Count().Equals(17)); Assert.True(response.Response.Body.Count().Equals(17));
} }
[Fact]
public async Task UrlHandlersTest()
{
var response = await Mpc.SendAsync(new Commands.Reflection.UrlHandlers());
TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Body.Count()}) Result:");
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
Assert.True(response.Response.Body.Count().Equals(11));
}
} }
} }