From ef57b0a76bd79663c59d0b571219fdccf4d33b4b Mon Sep 17 00:00:00 2001 From: glucaci Date: Tue, 20 Dec 2016 11:31:48 +0100 Subject: [PATCH] UrlHandlers command implemented and tested. Print MPD version in test. --- LibMpc/Commands/Commands.Reflection.cs | 13 ++++++++++++- LibMpc/Mpc.cs | 1 + LibMpcTest/MpcMock.cs | 2 +- LibMpcTest/Tests/ReflectionCommandsTest.cs | 11 +++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/LibMpc/Commands/Commands.Reflection.cs b/LibMpc/Commands/Commands.Reflection.cs index 90140bf..15f6282 100644 --- a/LibMpc/Commands/Commands.Reflection.cs +++ b/LibMpc/Commands/Commands.Reflection.cs @@ -41,7 +41,18 @@ namespace LibMpc } } - // TODO: urlhandlers + public class UrlHandlers : IMpcCommand> + { + public string Value => "urlhandlers"; + + public IEnumerable FormatResponse(IList> response) + { + var result = response.Where(item => item.Key.Equals("handler")).Select(item => item.Value); + + return result; + } + } + // TODO: decoders } } diff --git a/LibMpc/Mpc.cs b/LibMpc/Mpc.cs index 1a23a04..0952a41 100644 --- a/LibMpc/Mpc.cs +++ b/LibMpc/Mpc.cs @@ -24,6 +24,7 @@ namespace LibMpc } public bool IsConnected => _connection?.IsConnected ?? false; + public string Version => _connection?.Version ?? "Unknown"; public async Task ConnectAsync() { diff --git a/LibMpcTest/MpcMock.cs b/LibMpcTest/MpcMock.cs index 51ab76c..986e935 100644 --- a/LibMpcTest/MpcMock.cs +++ b/LibMpcTest/MpcMock.cs @@ -12,7 +12,7 @@ namespace LibMpcTest Client = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600)); 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; } diff --git a/LibMpcTest/Tests/ReflectionCommandsTest.cs b/LibMpcTest/Tests/ReflectionCommandsTest.cs index 3676fa6..b24fcbe 100644 --- a/LibMpcTest/Tests/ReflectionCommandsTest.cs +++ b/LibMpcTest/Tests/ReflectionCommandsTest.cs @@ -31,5 +31,16 @@ namespace LibMpcTest 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)); + } } } \ No newline at end of file