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 // 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); return results;
public IDictionary<string, string> FormatResponse(IList<KeyValuePair<string, string>> response)
{
return response.ToDefaultDictionary();
} }
} }

View File

@ -25,25 +25,39 @@ namespace LibMpcTest
var connected = Task.Run(async () => await _mpc.ConnectAsync()).Result; var connected = Task.Run(async () => await _mpc.ConnectAsync()).Result;
if (connected) if (connected)
{ {
Console.Out.WriteLine();
Console.Out.WriteLine("Connected to MPD."); Console.Out.WriteLine("Connected to MPD.");
} }
else else
{ {
Console.Out.WriteLine();
Console.Out.WriteLine("Could not connect to MPD."); Console.Out.WriteLine("Could not connect to MPD.");
} }
} }
[Fact] [Fact]
public async Task ListAllTest() public async Task TagTypesTest()
{ {
var response = await _mpc.SendAsync(new Commands.Reflection.TagTypes()); var response = await _mpc.SendAsync(new Commands.Reflection.TagTypes());
Console.Out.WriteLine();
Console.Out.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented)); Console.Out.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
Assert.True(response.Response.Body.Keys.Contains("tagtypes")); Assert.True(response.Response.Body.Keys.Contains("tagtypes"));
Assert.True(response.Response.Body.Values.Any()); 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() public void Dispose()
{ {
_mpc?.DisconnectAsync().GetAwaiter().GetResult(); _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}"); Console.Out.WriteLine($"Starting Server: {Process.StartInfo.FileName} {Process.StartInfo.Arguments}");
Process.Start(); Process.Start();
Console.Out.WriteLine("mpd:"); Console.Out.WriteLine($"Output: {Process.StandardOutput.ReadToEnd()}");
Console.Out.WriteLine($"out: {Process.StandardOutput.ReadToEnd()}"); Console.Out.WriteLine($"Error: {Process.StandardError.ReadToEnd()}");
Console.Out.WriteLine($"err: {Process.StandardError.ReadToEnd()}");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{ {
@ -60,9 +60,10 @@ namespace LibMpcTest
netcat.Start(); netcat.Start();
netcat.WaitForExit(); netcat.WaitForExit();
Console.Out.WriteLine("netstat:"); Console.Out.WriteLine();
Console.Out.WriteLine($"out: {netcat.StandardOutput.ReadToEnd()}"); Console.Out.WriteLine("netstat -ntpl");
Console.Out.WriteLine($"err: {netcat.StandardError.ReadToEnd()}"); Console.Out.WriteLine($"Output: {netcat.StandardOutput.ReadToEnd()}");
Console.Out.WriteLine($"Error: {netcat.StandardError.ReadToEnd()}");
} }
private Server GetServer() private Server GetServer()