From b54500053cfaecd9b6322b5b0f8a79a769521a8c Mon Sep 17 00:00:00 2001 From: glucaci Date: Fri, 16 Dec 2016 13:05:20 +0100 Subject: [PATCH] Future test to check if config is loaded correctly on build server --- LibMpc/Commands/Commands.Database.cs | 21 ++++++++++++--------- LibMpcTest/LibMpcTest.cs | 16 +++++++++++++++- LibMpcTest/MpdServerTest.cs | 13 +++++++------ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/LibMpc/Commands/Commands.Database.cs b/LibMpc/Commands/Commands.Database.cs index 164094a..20d78d0 100644 --- a/LibMpc/Commands/Commands.Database.cs +++ b/LibMpc/Commands/Commands.Database.cs @@ -67,20 +67,23 @@ namespace LibMpc // TODO: findadd - public class ListAll : IMpcCommand + public class ListAll : IMpcCommand>> { - private readonly string _path; + public string Value => "listall"; - public ListAll(string path) + public IDictionary>> FormatResponse(IList> response) { - _path = path; - } + var results = new Dictionary>> + { + { "result", new List>() } + }; - public string Value => string.Join(" ", "listall", _path); + foreach (var keyValuePair in response) + { + results["result"].Add(keyValuePair); + } - public IDictionary FormatResponse(IList> response) - { - return response.ToDefaultDictionary(); + return results; } } diff --git a/LibMpcTest/LibMpcTest.cs b/LibMpcTest/LibMpcTest.cs index cff4c18..ce807e8 100644 --- a/LibMpcTest/LibMpcTest.cs +++ b/LibMpcTest/LibMpcTest.cs @@ -25,25 +25,39 @@ namespace LibMpcTest var connected = Task.Run(async () => await _mpc.ConnectAsync()).Result; if (connected) { + Console.Out.WriteLine(); Console.Out.WriteLine("Connected to MPD."); } else { + Console.Out.WriteLine(); Console.Out.WriteLine("Could not connect to MPD."); } } [Fact] - public async Task ListAllTest() + public async Task TagTypesTest() { var response = await _mpc.SendAsync(new Commands.Reflection.TagTypes()); + Console.Out.WriteLine(); Console.Out.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented)); Assert.True(response.Response.Body.Keys.Contains("tagtypes")); Assert.True(response.Response.Body.Values.Any()); } + [Fact] + public async Task ListAllTest() + { + var response = await _mpc.SendAsync(new Commands.Database.ListAll()); + + Console.Out.WriteLine(); + Console.Out.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented)); + + // TODO: Assert + } + public void Dispose() { _mpc?.DisconnectAsync().GetAwaiter().GetResult(); diff --git a/LibMpcTest/MpdServerTest.cs b/LibMpcTest/MpdServerTest.cs index 40e0118..76e3684 100644 --- a/LibMpcTest/MpdServerTest.cs +++ b/LibMpcTest/MpdServerTest.cs @@ -27,13 +27,13 @@ namespace LibMpcTest } }; + Console.Out.WriteLine(); Console.Out.WriteLine($"Starting Server: {Process.StartInfo.FileName} {Process.StartInfo.Arguments}"); Process.Start(); - Console.Out.WriteLine("mpd:"); - Console.Out.WriteLine($"out: {Process.StandardOutput.ReadToEnd()}"); - Console.Out.WriteLine($"err: {Process.StandardError.ReadToEnd()}"); + Console.Out.WriteLine($"Output: {Process.StandardOutput.ReadToEnd()}"); + Console.Out.WriteLine($"Error: {Process.StandardError.ReadToEnd()}"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { @@ -60,9 +60,10 @@ namespace LibMpcTest netcat.Start(); netcat.WaitForExit(); - Console.Out.WriteLine("netstat:"); - Console.Out.WriteLine($"out: {netcat.StandardOutput.ReadToEnd()}"); - Console.Out.WriteLine($"err: {netcat.StandardError.ReadToEnd()}"); + Console.Out.WriteLine(); + Console.Out.WriteLine("netstat -ntpl"); + Console.Out.WriteLine($"Output: {netcat.StandardOutput.ReadToEnd()}"); + Console.Out.WriteLine($"Error: {netcat.StandardError.ReadToEnd()}"); } private Server GetServer()