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

Future test to check if config is loaded correctly on build server

This commit is contained in:
glucaci 2016-12-16 13:05:20 +01:00
parent de4743f7ea
commit b54500053c
3 changed files with 34 additions and 16 deletions

View File

@ -67,20 +67,23 @@ namespace LibMpc
// TODO: findadd
public class ListAll : IMpcCommand<string>
public class ListAll : IMpcCommand<IList<KeyValuePair<string, string>>>
{
private readonly string _path;
public string Value => "listall";
public ListAll(string path)
public IDictionary<string, IList<KeyValuePair<string, string>>> FormatResponse(IList<KeyValuePair<string, string>> response)
{
_path = path;
var results = new Dictionary<string, IList<KeyValuePair<string, string>>>
{
{ "result", new List<KeyValuePair<string, string>>() }
};
foreach (var keyValuePair in response)
{
results["result"].Add(keyValuePair);
}
public string Value => string.Join(" ", "listall", _path);
public IDictionary<string, string> FormatResponse(IList<KeyValuePair<string, string>> response)
{
return response.ToDefaultDictionary();
return results;
}
}

View File

@ -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();

View File

@ -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()