From 36a48887890c66a9f79811995b2040fef73874aa Mon Sep 17 00:00:00 2001 From: glucaci Date: Tue, 20 Dec 2016 11:19:26 +0100 Subject: [PATCH] "Commands" command created and tested --- LibMpc/Commands/Commands.Reflection.cs | 17 ++++++++++++++++- LibMpcTest/Tests/ReflectionCommandsTest.cs | 11 +++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/LibMpc/Commands/Commands.Reflection.cs b/LibMpc/Commands/Commands.Reflection.cs index 9d4506e..90140bf 100644 --- a/LibMpc/Commands/Commands.Reflection.cs +++ b/LibMpc/Commands/Commands.Reflection.cs @@ -11,7 +11,22 @@ namespace LibMpc public static class Reflection { // TODO: config - // TODO: commands + + /// + /// Shows which commands the current user has access to. + /// + public class Commands : IMpcCommand> + { + public string Value => "commands"; + + public IEnumerable FormatResponse(IList> response) + { + var result = response.Where(item => item.Key.Equals("command")).Select(item => item.Value); + + return result; + } + } + // TODO: notcommands public class TagTypes : IMpcCommand> diff --git a/LibMpcTest/Tests/ReflectionCommandsTest.cs b/LibMpcTest/Tests/ReflectionCommandsTest.cs index 4f3afe7..9830732 100644 --- a/LibMpcTest/Tests/ReflectionCommandsTest.cs +++ b/LibMpcTest/Tests/ReflectionCommandsTest.cs @@ -8,6 +8,17 @@ namespace LibMpcTest { public partial class LibMpcTest { + [Fact] + public async Task CommandsTest() + { + var response = await Mpc.SendAsync(new Commands.Reflection.Commands()); + + TestOutput.WriteLine($"CommandsTest (commands: {response.Response.Body.Count()}) Result:"); + TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented)); + + Assert.True(response.Response.Body.Count().Equals(84)); + } + [Fact] public async Task TagTypesTest() {