1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-07-18 05:27:37 +00:00

Major refactoring

This commit is contained in:
Kim Hugener-Ohlsen
2018-05-18 15:14:20 +02:00
parent 245efd6477
commit 12ddc4bca4
99 changed files with 426 additions and 419 deletions

View File

@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MpcNET.Test
namespace MpcNET.Test
{
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public partial class LibMpcTest
{
@ -25,29 +25,34 @@ namespace MpcNET.Test
_mpdMock.Dispose();
}
internal static Mpc Mpc { get; private set; }
internal static MpcConnection Mpc { get; private set; }
private static async Task SendCommand(string command)
{
var response = await Mpc.SendAsync(new PassthroughCommand(command));
var response = await Mpc.SendAsync(_ => new PassthroughCommand(command));
TestOutput.WriteLine(response);
}
private static async Task SendCommand<T>(IMpcCommand<T> command)
{
var response = await Mpc.SendAsync(command);
var response = await Mpc.SendAsync(_ => command);
TestOutput.WriteLine(response);
}
private class PassthroughCommand : IMpcCommand<IList<string>>
{
private readonly string command;
public PassthroughCommand(string command)
{
Value = command;
this.command = command;
}
public string Value { get; }
public string Serialize()
{
return this.command;
}
public IList<string> FormatResponse(IList<KeyValuePair<string, string>> response)
public IList<string> Deserialize(IReadOnlyList<KeyValuePair<string, string>> response)
{
var result = response.Select(atrb => $"{atrb.Key}: {atrb.Value}").ToList();
return result;

View File

@ -1,25 +1,25 @@
using System;
using System.Net;
using System.Threading.Tasks;
namespace MpcNET.Test
{
using System;
using System.Net;
using System.Threading.Tasks;
public class MpcMock : IDisposable
{
public MpcMock()
{
var mpdEndpoint = new IPEndPoint(IPAddress.Loopback, 6600);
Client = new Mpc(mpdEndpoint);
this.Client = new MpcConnection(mpdEndpoint);
var connected = Task.Run(async () => await Client.ConnectAsync()).Result;
TestOutput.WriteLine($"Connected to MPD : {connected}; Version: {Client.Version}");
Task.Run(async () => await this.Client.ConnectAsync()).Wait();
TestOutput.WriteLine($"Connected to MPD Version: {this.Client.Version}");
}
public Mpc Client { get; }
public MpcConnection Client { get; }
public void Dispose()
{
Client?.DisconnectAsync().GetAwaiter().GetResult();
this.Client?.DisconnectAsync().GetAwaiter().GetResult();
TestOutput.WriteLine($"Disconnected from MPD.");
}
}

View File

@ -24,9 +24,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.0" />
</ItemGroup>
<ItemGroup>

View File

@ -1,8 +1,8 @@
using System.IO;
using System.Text;
namespace MpcNET.Test
{
using System.IO;
using System.Text;
public class MpdConf
{
private const string MPD_CONF_FILE = "mpd.conf";

View File

@ -1,24 +1,24 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace MpcNET.Test
{
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
public class MpdMock : IDisposable
{
public void Start()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
SendCommand("/usr/bin/pkill mpd");
this.SendCommand("/usr/bin/pkill mpd");
}
MpdConf.Create(Path.Combine(AppContext.BaseDirectory, "Server"));
var server = GetServer();
var server = this.GetServer();
Process = new Process
this.Process = new Process
{
StartInfo = new ProcessStartInfo
{
@ -32,15 +32,15 @@ namespace MpcNET.Test
}
};
TestOutput.WriteLine($"Starting Server: {Process.StartInfo.FileName} {Process.StartInfo.Arguments}");
TestOutput.WriteLine($"Starting Server: {this.Process.StartInfo.FileName} {this.Process.StartInfo.Arguments}");
Process.Start();
TestOutput.WriteLine($"Output: {Process.StandardOutput.ReadToEnd()}");
TestOutput.WriteLine($"Error: {Process.StandardError.ReadToEnd()}");
this.Process.Start();
TestOutput.WriteLine($"Output: {this.Process.StandardOutput.ReadToEnd()}");
TestOutput.WriteLine($"Error: {this.Process.StandardError.ReadToEnd()}");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
SendCommand("/bin/netstat -ntpl");
this.SendCommand("/bin/netstat -ntpl");
}
}
@ -87,8 +87,8 @@ namespace MpcNET.Test
public void Dispose()
{
Process?.Kill();
Process?.Dispose();
this.Process?.Kill();
this.Process?.Dispose();
TestOutput.WriteLine("Server Stopped.");
}
@ -106,9 +106,9 @@ namespace MpcNET.Test
private Server(string fileName, string workingDirectory, string arguments)
{
FileName = fileName;
WorkingDirectory = workingDirectory;
Arguments = arguments;
this.FileName = fileName;
this.WorkingDirectory = workingDirectory;
this.Arguments = arguments;
}
public string FileName { get; }

View File

@ -1,8 +1,8 @@
using System;
using MpcNET.Message;
namespace MpcNET.Test
namespace MpcNET.Test
{
using System;
using MpcNET.Message;
internal static class TestOutput
{
internal static void WriteLine(string value)

View File

@ -1,33 +1,33 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
using MpcNET.Tags;
namespace MpcNET.Test
{
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
using MpcNET.Tags;
public partial class LibMpcTest
{
[TestMethod]
public async Task ListAllTest()
{
var response = await Mpc.SendAsync(Command.Database.ListAll());
var response = await Mpc.SendAsync(commands => commands.Database.ListAll());
TestOutput.WriteLine("ListAllTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(7));
Assert.IsTrue(response.Response.Content.Count().Equals(7));
}
[TestMethod]
public async Task FindGenreTest()
{
var response = await Mpc.SendAsync(Command.Database.Find(MpdTags.Genre, "soundfx"));
var response = await Mpc.SendAsync(commands => commands.Database.Find(MpdTags.Genre, "soundfx"));
TestOutput.WriteLine("FindGenreTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(7));
Assert.IsTrue(response.Response.Content.Count().Equals(7));
}
}
}

View File

@ -1,16 +1,16 @@
using MpcNET.Message;
namespace MpcNET.Test
{
using MpcNET.Message;
public static class MpdMessageExtension
{
public static bool HasSuccessResponse<T>(this IMpdMessage<T> message)
{
return message.Response.State.Connected &&
message.Response.State.Status == "OK" &&
!message.Response.State.Error &&
message.Response.State.ErrorMessage == string.Empty &&
message.Response.State.MpdError == string.Empty;
return message.Response.Result.Connected &&
message.Response.Result.Status == "OK" &&
!message.Response.Result.Error &&
message.Response.Result.ErrorMessage == string.Empty &&
message.Response.Result.MpdError == string.Empty;
}
}
}

View File

@ -1,76 +1,75 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
namespace MpcNET.Test
{
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public partial class LibMpcTest
{
[TestMethod]
public async Task DisableOutputTest()
{
var responseOutputs = await Mpc.SendAsync(Command.Output.Outputs());
Assert.IsTrue(responseOutputs.Response.Body.Single(output => output.Id.Equals(0)).IsEnabled);
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled);
var response = await Mpc.SendAsync(Command.Output.DisableOutput(0));
var response = await Mpc.SendAsync(commands => commands.Output.DisableOutput(0));
TestOutput.WriteLine("DisableOutputTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Equals(string.Empty));
Assert.IsTrue(response.Response.State.Status.Equals("OK"));
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(Command.Output.Outputs());
Assert.IsFalse(responseOutputs.Response.Body.Single(output => output.Id.Equals(0)).IsEnabled);
responseOutputs = await Mpc.SendAsync(c => c.Output.Outputs());
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled);
}
[TestMethod]
public async Task EnableOutputTest()
{
var responseOutputs = await Mpc.SendAsync(Command.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
// By default should be disable from mpd.config
Assert.IsFalse(responseOutputs.Response.Body.Single(output => output.Id.Equals(1)).IsEnabled);
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled);
var response = await Mpc.SendAsync(Command.Output.EnableOutput(1));
var response = await Mpc.SendAsync(commands => commands.Output.EnableOutput(1));
TestOutput.WriteLine("EnableOutputTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Equals(string.Empty));
Assert.IsTrue(response.Response.State.Status.Equals("OK"));
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(Command.Output.Outputs());
Assert.IsTrue(responseOutputs.Response.Body.Single(output => output.Id.Equals(1)).IsEnabled);
responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled);
}
[TestMethod]
public async Task ToggleOutputTest()
{
var responseOutputs = await Mpc.SendAsync(Command.Output.Outputs());
Assert.IsTrue(responseOutputs.Response.Body.Single(output => output.Id.Equals(2)).IsEnabled);
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(2)).IsEnabled);
var response = await Mpc.SendAsync(Command.Output.ToggleOutput(2));
var response = await Mpc.SendAsync(commands => commands.Output.ToggleOutput(2));
TestOutput.WriteLine("ToggleOutputTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Equals(string.Empty));
Assert.IsTrue(response.Response.State.Status.Equals("OK"));
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(Command.Output.Outputs());
Assert.IsFalse(responseOutputs.Response.Body.Single(output => output.Id.Equals(2)).IsEnabled);
responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(2)).IsEnabled);
}
[TestMethod]
public async Task LisOutputsTest()
{
var response = await Mpc.SendAsync(Command.Output.Outputs());
var response = await Mpc.SendAsync(commands => commands.Output.Outputs());
TestOutput.WriteLine("LisOutputsTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(3));
Assert.IsTrue(response.Response.Content.Count().Equals(3));
}
}
}

View File

@ -1,10 +1,10 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
namespace MpcNET.Test
namespace MpcNET.Test
{
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
public partial class LibMpcTest
{
[DataTestMethod]
@ -13,12 +13,12 @@ namespace MpcNET.Test
[DataRow("_My Playlist", 5)]
public async Task ListPlaylistTest(string playlistName, int numberOfFiles)
{
var response = await Mpc.SendAsync(Command.Playlists.Stored.GetContent(playlistName));
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetContent(playlistName));
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(numberOfFiles));
Assert.IsTrue(response.Response.Content.Count().Equals(numberOfFiles));
}
[DataTestMethod]
@ -27,26 +27,26 @@ namespace MpcNET.Test
[DataRow("_My Playlist", 5)]
public async Task ListPlaylistInfoTest(string playlistName, int numberOfFiles)
{
var response = await Mpc.SendAsync(Command.Playlists.Stored.GetContentWithMetadata(playlistName));
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetContentWithMetadata(playlistName));
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(numberOfFiles));
Assert.IsTrue(response.Response.Body.All(item => !string.IsNullOrEmpty(item.Artist)));
Assert.IsTrue(response.Response.Body.All(item => !string.IsNullOrEmpty(item.Title)));
Assert.IsTrue(response.Response.Body.All(item => !string.IsNullOrEmpty(item.Date)));
Assert.IsTrue(response.Response.Content.Count().Equals(numberOfFiles));
Assert.IsTrue(response.Response.Content.All(item => !string.IsNullOrEmpty(item.Artist)));
Assert.IsTrue(response.Response.Content.All(item => !string.IsNullOrEmpty(item.Title)));
Assert.IsTrue(response.Response.Content.All(item => !string.IsNullOrEmpty(item.Date)));
}
[TestMethod]
public async Task ListPlaylistsTest()
{
var response = await Mpc.SendAsync(Command.Playlists.Stored.GetAll());
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetAll());
TestOutput.WriteLine($"ListPlaylistsTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(3));
Assert.IsTrue(response.Response.Content.Count().Equals(3));
}
/// <summary>
@ -55,120 +55,120 @@ namespace MpcNET.Test
[TestMethod]
public async Task QueueTests()
{
await LoadPlaylistTest();
await ClearPlaylistTest();
await AddDirectoryTest();
await AddFileTest();
await RemovePositionTest();
await RemoveIdTest();
await this.LoadPlaylistTest();
await this.ClearPlaylistTest();
await this.AddDirectoryTest();
await this.AddFileTest();
await this.RemovePositionTest();
await this.RemoveIdTest();
}
public async Task LoadPlaylistTest()
{
await Clear_Queue();
await Check_Empty_Queue();
await Load_Playlist("Playlist One");
await Check_Queue_HasSongs(5);
await this.Clear_Queue();
await this.Check_Empty_Queue();
await this.Load_Playlist("Playlist One");
await this.Check_Queue_HasSongs(5);
}
public async Task ClearPlaylistTest()
{
await Clear_Queue();
await Check_Empty_Queue();
await Load_Playlist("Playlist One");
await Clear_Queue();
await Check_Queue_HasSongs(0);
await this.Clear_Queue();
await this.Check_Empty_Queue();
await this.Load_Playlist("Playlist One");
await this.Clear_Queue();
await this.Check_Queue_HasSongs(0);
}
public async Task AddDirectoryTest()
{
await Clear_Queue();
await Check_Empty_Queue();
await Add_Directory("Directory With Spaces");
await Check_Queue_HasSongs(3);
await this.Clear_Queue();
await this.Check_Empty_Queue();
await this.Add_Directory("Directory With Spaces");
await this.Check_Queue_HasSongs(3);
}
public async Task AddFileTest()
{
await Clear_Queue();
await Check_Empty_Queue();
await Add_File("teaspoon-stirring-mug-of-coffee.mp3");
await Check_Queue_HasSongs(1);
await this.Clear_Queue();
await this.Check_Empty_Queue();
await this.Add_File("teaspoon-stirring-mug-of-coffee.mp3");
await this.Check_Queue_HasSongs(1);
}
public async Task RemovePositionTest()
{
await Clear_Queue();
await Check_Empty_Queue();
await Add_File("teaspoon-stirring-mug-of-coffee.mp3");
await Remove_Position(0);
await Check_Queue_HasSongs(0);
await this.Clear_Queue();
await this.Check_Empty_Queue();
await this.Add_File("teaspoon-stirring-mug-of-coffee.mp3");
await this.Remove_Position(0);
await this.Check_Queue_HasSongs(0);
}
public async Task RemoveIdTest()
{
await Clear_Queue();
await Check_Empty_Queue();
await Add_File("teaspoon-stirring-mug-of-coffee.mp3");
var id = await Get_Song_Id();
await Remove_Id(id);
await Check_Queue_HasSongs(0);
await this.Clear_Queue();
await this.Check_Empty_Queue();
await this.Add_File("teaspoon-stirring-mug-of-coffee.mp3");
var id = await this.Get_Song_Id();
await this.Remove_Id(id);
await this.Check_Queue_HasSongs(0);
}
private async Task Check_Empty_Queue()
{
var message = await Mpc.SendAsync(Command.Playlists.Current.GetAllSongsInfo());
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongsInfo());
Assert.IsTrue(message.HasSuccessResponse());
Assert.IsFalse(message.Response.Body.Any());
Assert.IsFalse(message.Response.Content.Any());
}
private async Task Load_Playlist(string playlistName)
{
var message = await Mpc.SendAsync(Command.Playlists.Stored.Load(playlistName));
var message = await Mpc.SendAsync(commands => commands.StoredPlaylist.Load(playlistName));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Clear_Queue()
{
var message = await Mpc.SendAsync(Command.Playlists.Current.Clear());
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.Clear());
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Check_Queue_HasSongs(int nrOfSongs)
{
var message = await Mpc.SendAsync(Command.Playlists.Current.GetAllSongsInfo());
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongsInfo());
Assert.IsTrue(message.HasSuccessResponse());
Assert.IsTrue(message.Response.Body.Count() == nrOfSongs);
Assert.IsTrue(message.Response.Content.Count() == nrOfSongs);
}
private async Task Add_Directory(string directory)
{
var message = await Mpc.SendAsync(Command.Playlists.Current.AddDirectory(directory));
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.AddDirectory(directory));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Add_File(string file)
{
var message = await Mpc.SendAsync(Command.Playlists.Current.AddSong(file));
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.AddSong(file));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Remove_Position(int position)
{
var message = await Mpc.SendAsync(Command.Playlists.Current.RemoveSongByPosition(position));
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.RemoveSongByPosition(position));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Remove_Id(int songId)
{
var message = await Mpc.SendAsync(Command.Playlists.Current.RemoveSongById(songId));
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.RemoveSongById(songId));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task<int> Get_Song_Id()
{
var message = await Mpc.SendAsync(Command.Playlists.Current.GetAllSongMetadata());
return message.Response.Body.Single().Id;
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongMetadata());
return message.Response.Content.Single().Id;
}
}
}

View File

@ -1,79 +1,79 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
namespace MpcNET.Test
{
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MpcNET.Commands;
public partial class LibMpcTest
{
[TestMethod]
public async Task CommandsTest()
{
var response = await Mpc.SendAsync(Command.Reflection.Commands());
var response = await Mpc.SendAsync(commands => commands.Reflection.Commands());
TestOutput.WriteLine($"CommandsTest (commands: {response.Response.Body.Count()}) Result:");
TestOutput.WriteLine($"CommandsTest (commands: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
// Different answer from MPD on Windows and on Linux, beacuse of Version.
// Check some of the commands.
Assert.IsTrue(response.Response.Body.Any(command => command.Equals("listall")));
Assert.IsTrue(response.Response.Body.Any(command => command.Equals("outputs")));
Assert.IsTrue(response.Response.Body.Any(command => command.Equals("pause")));
Assert.IsTrue(response.Response.Body.Any(command => command.Equals("play")));
Assert.IsTrue(response.Response.Body.Any(command => command.Equals("setvol")));
Assert.IsTrue(response.Response.Body.Any(command => command.Equals("stop")));
Assert.IsTrue(response.Response.Content.Any(command => command.Equals("listall")));
Assert.IsTrue(response.Response.Content.Any(command => command.Equals("outputs")));
Assert.IsTrue(response.Response.Content.Any(command => command.Equals("pause")));
Assert.IsTrue(response.Response.Content.Any(command => command.Equals("play")));
Assert.IsTrue(response.Response.Content.Any(command => command.Equals("setvol")));
Assert.IsTrue(response.Response.Content.Any(command => command.Equals("stop")));
}
[TestMethod]
public async Task TagTypesTest()
{
var response = await Mpc.SendAsync(Command.Reflection.TagTypes());
var response = await Mpc.SendAsync(commands => commands.Reflection.TagTypes());
TestOutput.WriteLine("TagTypesTest Result:");
TestOutput.WriteLine(response);
Assert.IsTrue(response.Response.Body.Count().Equals(17));
Assert.IsTrue(response.Response.Content.Count().Equals(17));
}
[TestMethod]
public async Task UrlHandlersTest()
{
var response = await Mpc.SendAsync(Command.Reflection.UrlHandlers());
var response = await Mpc.SendAsync(commands => commands.Reflection.UrlHandlers());
TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Body.Count()}) Result:");
TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
// Different answer from MPD on Windows and on Linux.
// Check some of the handlers.
Assert.IsTrue(response.Response.Body.Any(handler => handler.Equals("http://")));
Assert.IsTrue(response.Response.Body.Any(handler => handler.Equals("mms://")));
Assert.IsTrue(response.Response.Body.Any(handler => handler.Equals("gopher://")));
Assert.IsTrue(response.Response.Body.Any(handler => handler.Equals("rtp://")));
Assert.IsTrue(response.Response.Content.Any(handler => handler.Equals("http://")));
Assert.IsTrue(response.Response.Content.Any(handler => handler.Equals("mms://")));
Assert.IsTrue(response.Response.Content.Any(handler => handler.Equals("gopher://")));
Assert.IsTrue(response.Response.Content.Any(handler => handler.Equals("rtp://")));
}
[TestMethod]
public async Task DecodersTest()
{
var response = await Mpc.SendAsync(Command.Reflection.Decoders());
var response = await Mpc.SendAsync(commands => commands.Reflection.Decoders());
TestOutput.WriteLine($"DecodersTest (decoders: {response.Response.Body.Count()}) Result:");
TestOutput.WriteLine($"DecodersTest (decoders: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
// Different answer from MPD on Windows and on Linux.
// Check some of the decoders.
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Name.Equals("mad")));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("mp3"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/mpeg"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Name.Equals("flac")));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("flac"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/flac"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/x-flac"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Name.Equals("ffmpeg")));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("aac"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("mpeg"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/aac"))));
Assert.IsTrue(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/mpeg"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Name.Equals("mad")));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("mp3"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/mpeg"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Name.Equals("flac")));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("flac"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/flac"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/x-flac"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Name.Equals("ffmpeg")));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("aac"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("mpeg"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/aac"))));
Assert.IsTrue(response.Response.Content.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/mpeg"))));
}
}
}