mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-07-01 16:47:37 +00:00
Merge from refactoringResponse branch
This commit is contained in:
@ -1,65 +1,15 @@
|
||||
using LibMpc;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
public class LibMpcTest : IClassFixture<MpdServerTest>, IDisposable
|
||||
public partial class LibMpcTest : IClassFixture<MpdMock>, IClassFixture<MpcMock>
|
||||
{
|
||||
private readonly MpdServerTest _server;
|
||||
private readonly ITestOutputHelper _output;
|
||||
private readonly Mpc _mpc;
|
||||
|
||||
public LibMpcTest(MpdServerTest server, ITestOutputHelper output)
|
||||
public LibMpcTest(MpcMock mpc)
|
||||
{
|
||||
_server = server;
|
||||
_output = output;
|
||||
|
||||
_mpc = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
|
||||
|
||||
var connected = Task.Run(async () => await _mpc.ConnectAsync()).Result;
|
||||
if (connected)
|
||||
{
|
||||
Console.Out.WriteLine("Connected to MPD.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Out.WriteLine("Could not connect to MPD.");
|
||||
}
|
||||
Mpc = mpc.Client;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TagTypesTest()
|
||||
{
|
||||
var response = await _mpc.SendAsync(new Commands.Reflection.TagTypes());
|
||||
|
||||
Console.Out.WriteLine("TagTypesTest Result:");
|
||||
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("ListAllTest Result:");
|
||||
Console.Out.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Keys.Contains("directories"));
|
||||
Assert.True(response.Response.Body["directories"].Count.Equals(5));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_mpc?.DisconnectAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
internal Mpc Mpc { get; }
|
||||
}
|
||||
}
|
||||
|
26
LibMpcTest/MpcMock.cs
Normal file
26
LibMpcTest/MpcMock.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using LibMpc;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
public class MpcMock : IDisposable
|
||||
{
|
||||
public MpcMock()
|
||||
{
|
||||
Client = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
|
||||
|
||||
var connected = Task.Run(async () => await Client.ConnectAsync()).Result;
|
||||
TestOutput.WriteLine($"Connected to MPD : {connected}; Version: {Client.Version}");
|
||||
}
|
||||
|
||||
public Mpc Client { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Client?.DisconnectAsync().GetAwaiter().GetResult();
|
||||
TestOutput.WriteLine($"Disconnected from MPD.");
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,20 @@ namespace LibMpcTest
|
||||
builder.AppendLine("port \"6600\"");
|
||||
builder.AppendLine("audio_output {");
|
||||
builder.AppendLine("type \"null\"");
|
||||
builder.AppendLine("name \"No Output\"");
|
||||
builder.AppendLine("name \"Enabled output to be disabled\"");
|
||||
builder.AppendLine("enabled \"true\"");
|
||||
builder.AppendLine("mixer_type \"none\"");
|
||||
builder.AppendLine("}");
|
||||
builder.AppendLine("audio_output {");
|
||||
builder.AppendLine("type \"null\"");
|
||||
builder.AppendLine("name \"Disabled output to be enabled\"");
|
||||
builder.AppendLine("enabled \"false\"");
|
||||
builder.AppendLine("mixer_type \"none\"");
|
||||
builder.AppendLine("}");
|
||||
builder.AppendLine("audio_output {");
|
||||
builder.AppendLine("type \"null\"");
|
||||
builder.AppendLine("name \"Enabled output to be toggled\"");
|
||||
builder.AppendLine("enabled \"true\"");
|
||||
builder.AppendLine("mixer_type \"none\"");
|
||||
builder.AppendLine("}");
|
||||
|
||||
|
@ -5,9 +5,9 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
public class MpdServerTest : IDisposable
|
||||
public class MpdMock : IDisposable
|
||||
{
|
||||
public MpdServerTest()
|
||||
public MpdMock()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
@ -32,11 +32,11 @@ namespace LibMpcTest
|
||||
}
|
||||
};
|
||||
|
||||
Console.Out.WriteLine($"Starting Server: {Process.StartInfo.FileName} {Process.StartInfo.Arguments}");
|
||||
TestOutput.WriteLine($"Starting Server: {Process.StartInfo.FileName} {Process.StartInfo.Arguments}");
|
||||
|
||||
Process.Start();
|
||||
Console.Out.WriteLine($"Output: {Process.StandardOutput.ReadToEnd()}");
|
||||
Console.Out.WriteLine($"Error: {Process.StandardError.ReadToEnd()}");
|
||||
TestOutput.WriteLine($"Output: {Process.StandardOutput.ReadToEnd()}");
|
||||
TestOutput.WriteLine($"Error: {Process.StandardError.ReadToEnd()}");
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
@ -80,15 +80,16 @@ namespace LibMpcTest
|
||||
netcat.Start();
|
||||
netcat.WaitForExit();
|
||||
|
||||
Console.Out.WriteLine(command);
|
||||
Console.Out.WriteLine($"Output: {netcat.StandardOutput.ReadToEnd()}");
|
||||
Console.Out.WriteLine($"Error: {netcat.StandardError.ReadToEnd()}");
|
||||
TestOutput.WriteLine(command);
|
||||
TestOutput.WriteLine($"Output: {netcat.StandardOutput.ReadToEnd()}");
|
||||
TestOutput.WriteLine($"Error: {netcat.StandardError.ReadToEnd()}");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Process?.Kill();
|
||||
Process?.Dispose();
|
||||
TestOutput.WriteLine("Server Stopped.");
|
||||
}
|
||||
|
||||
private class Server
|
5
LibMpcTest/Server/Playlists/Playlist One.m3u
Normal file
5
LibMpcTest/Server/Playlists/Playlist One.m3u
Normal file
@ -0,0 +1,5 @@
|
||||
teaspoon-stirring-mug-of-coffee.mp3
|
||||
whistle-kettle-boiling.mp3
|
||||
wine-glass-double-chink-clink-cheers.mp3
|
||||
Directory With Spaces/coin-spin-light.mp3
|
||||
Directory With Spaces/finger-snap-click.mp3
|
3
LibMpcTest/Server/Playlists/Playlist Two.m3u
Normal file
3
LibMpcTest/Server/Playlists/Playlist Two.m3u
Normal file
@ -0,0 +1,3 @@
|
||||
A long name directory with some spaces/pouring-water-into-mug-of-coffee.mp3
|
||||
A long name directory with some spaces/Sub Directory Two/short-trouser-pants-zip-closing.mp3
|
||||
Directory/2-Kids-Laughing.mp3
|
5
LibMpcTest/Server/Playlists/_My Playlist.m3u
Normal file
5
LibMpcTest/Server/Playlists/_My Playlist.m3u
Normal file
@ -0,0 +1,5 @@
|
||||
A long name directory with some spaces/Ghost-Sounds.mp3
|
||||
Directory/ambient-noise-server-room.mp3
|
||||
Directory With Spaces/SubDirectory One/central-locking-Ford-Mondeo-Mk-3.mp3
|
||||
_My Directory/gas-fire-lighting.mp3
|
||||
A long name directory with some spaces/Sub Directory Two/starting-engine-Ford-Mondeo-Mk-3-diesel.mp3
|
@ -21,23 +21,36 @@ tag: MUSICBRAINZ_ALBUMARTISTID
|
||||
tag: MUSICBRAINZ_TRACKID
|
||||
info_end
|
||||
directory: A long name directory with some spaces
|
||||
mtime: 1481622608
|
||||
mtime: 1482142041
|
||||
begin: A long name directory with some spaces
|
||||
song_begin: pouring-water-into-mug-of-coffee.mp3
|
||||
Time: 4
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: pouring water into mug of coffee
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481622059
|
||||
song_end
|
||||
directory: Sub Directory Two
|
||||
mtime: 1482142041
|
||||
begin: A long name directory with some spaces/Sub Directory Two
|
||||
song_begin: short-trouser-pants-zip-closing.mp3
|
||||
Time: 1
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: short trouser pants zip closing
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481622066
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
song_begin: starting-engine-Ford-Mondeo-Mk-3-diesel.mp3
|
||||
Time: 6
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: starting engine - Ford Mondeo Mk 3 diesel
|
||||
Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
end: A long name directory with some spaces/Sub Directory Two
|
||||
song_begin: pouring-water-into-mug-of-coffee.mp3
|
||||
Time: 4
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: pouring water into mug of coffee
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
song_begin: Ghost-Sounds.mp3
|
||||
Time: 95
|
||||
@ -47,20 +60,11 @@ Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622054
|
||||
song_end
|
||||
song_begin: starting-engine-Ford-Mondeo-Mk-3-diesel.mp3
|
||||
Time: 6
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: starting engine - Ford Mondeo Mk 3 diesel
|
||||
Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622063
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
end: A long name directory with some spaces
|
||||
directory: Directory
|
||||
mtime: 1481622608
|
||||
mtime: 1482142041
|
||||
begin: Directory
|
||||
song_begin: 2-Kids-Laughing.mp3
|
||||
Time: 30
|
||||
@ -70,7 +74,7 @@ Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622083
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
song_begin: ambient-noise-server-room.mp3
|
||||
Time: 71
|
||||
@ -80,20 +84,15 @@ Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622020
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
end: Directory
|
||||
directory: Directory With Spaces
|
||||
mtime: 1481622608
|
||||
mtime: 1482142041
|
||||
begin: Directory With Spaces
|
||||
song_begin: coin-spin-light.mp3
|
||||
Time: 5
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: coin spin (light coin)
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481622036
|
||||
song_end
|
||||
directory: SubDirectory One
|
||||
mtime: 1482142041
|
||||
begin: Directory With Spaces/SubDirectory One
|
||||
song_begin: central-locking-Ford-Mondeo-Mk-3.mp3
|
||||
Time: 5
|
||||
Artist: Geek & Dummy
|
||||
@ -102,7 +101,16 @@ Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622024
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
end: Directory With Spaces/SubDirectory One
|
||||
song_begin: coin-spin-light.mp3
|
||||
Time: 5
|
||||
Artist: Geek & Dummy
|
||||
Title: Sound effect: coin spin (light coin)
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
song_begin: finger-snap-click.mp3
|
||||
Time: 0
|
||||
@ -112,11 +120,11 @@ Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622047
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
end: Directory With Spaces
|
||||
directory: _My Directory
|
||||
mtime: 1481622608
|
||||
mtime: 1482142041
|
||||
begin: _My Directory
|
||||
song_begin: gas-fire-lighting.mp3
|
||||
Time: 58
|
||||
@ -126,7 +134,7 @@ Album: Geek & Dummy Sound Library
|
||||
Date: 2014
|
||||
Date: 2014
|
||||
Genre: soundfx
|
||||
mtime: 1481622051
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
end: _My Directory
|
||||
song_begin: teaspoon-stirring-mug-of-coffee.mp3
|
||||
@ -135,7 +143,7 @@ Artist: Geek & Dummy
|
||||
Title: Sound effect: teaspoon stirring mug of coffee
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481622029
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
song_begin: whistle-kettle-boiling.mp3
|
||||
Time: 36
|
||||
@ -143,7 +151,7 @@ Artist: Geek & Dummy
|
||||
Title: Sound effect: whistle kettle boiling
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481622087
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
song_begin: wine-glass-double-chink-clink-cheers.mp3
|
||||
Time: 1
|
||||
@ -151,5 +159,5 @@ Artist: Geek & Dummy
|
||||
Title: Sound effect: wine glass double chink/clink/cheers
|
||||
Date: 2013
|
||||
Date: 2013
|
||||
mtime: 1481622090
|
||||
mtime: 1481623577
|
||||
song_end
|
||||
|
12
LibMpcTest/TestOutput.cs
Normal file
12
LibMpcTest/TestOutput.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
internal class TestOutput
|
||||
{
|
||||
internal static void WriteLine(string value)
|
||||
{
|
||||
Console.Out.WriteLine(value);
|
||||
}
|
||||
}
|
||||
}
|
33
LibMpcTest/Tests/DatabaseCommandsTest.cs
Normal file
33
LibMpcTest/Tests/DatabaseCommandsTest.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using System.Linq;
|
||||
using LibMpc;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
public partial class LibMpcTest
|
||||
{
|
||||
[Fact]
|
||||
public async Task ListAllTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Database.ListAll());
|
||||
|
||||
TestOutput.WriteLine("ListAllTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(7));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FindGenreTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Database.Find(MpdTags.Genre, "soundfx"));
|
||||
|
||||
TestOutput.WriteLine("FindGenreTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(7));
|
||||
}
|
||||
}
|
||||
}
|
77
LibMpcTest/Tests/OutputCommandsTest.cs
Normal file
77
LibMpcTest/Tests/OutputCommandsTest.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using LibMpc;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
public partial class LibMpcTest
|
||||
{
|
||||
[Fact]
|
||||
public async Task DisableOutputTest()
|
||||
{
|
||||
var responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
Assert.True(responseOutputs.Response.Body.Single(output => output.Id.Equals(0)).IsEnabled);
|
||||
|
||||
var response = await Mpc.SendAsync(new Commands.Output.DisableOutput(0));
|
||||
|
||||
TestOutput.WriteLine("DisableOutputTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Equals(string.Empty));
|
||||
Assert.True(response.Response.State.Status.Equals("OK"));
|
||||
|
||||
responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
Assert.False(responseOutputs.Response.Body.Single(output => output.Id.Equals(0)).IsEnabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnableOutputTest()
|
||||
{
|
||||
var responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
// By default should be disable from mpd.config
|
||||
Assert.False(responseOutputs.Response.Body.Single(output => output.Id.Equals(1)).IsEnabled);
|
||||
|
||||
var response = await Mpc.SendAsync(new Commands.Output.EnableOutput(1));
|
||||
|
||||
TestOutput.WriteLine("EnableOutputTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Equals(string.Empty));
|
||||
Assert.True(response.Response.State.Status.Equals("OK"));
|
||||
|
||||
responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
Assert.True(responseOutputs.Response.Body.Single(output => output.Id.Equals(1)).IsEnabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ToggleOutputTest()
|
||||
{
|
||||
var responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
Assert.True(responseOutputs.Response.Body.Single(output => output.Id.Equals(2)).IsEnabled);
|
||||
|
||||
var response = await Mpc.SendAsync(new Commands.Output.ToggleOutput(2));
|
||||
|
||||
TestOutput.WriteLine("ToggleOutputTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Equals(string.Empty));
|
||||
Assert.True(response.Response.State.Status.Equals("OK"));
|
||||
|
||||
responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
Assert.False(responseOutputs.Response.Body.Single(output => output.Id.Equals(2)).IsEnabled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LisOutputsTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Output.Outputs());
|
||||
|
||||
TestOutput.WriteLine("LisOutputsTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(3));
|
||||
}
|
||||
}
|
||||
}
|
54
LibMpcTest/Tests/PlaylistsCommandsTest.cs
Normal file
54
LibMpcTest/Tests/PlaylistsCommandsTest.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using LibMpc;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
public partial class LibMpcTest
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("Playlist One", 5)]
|
||||
[InlineData("Playlist Two", 3)]
|
||||
[InlineData("_My Playlist", 5)]
|
||||
public async Task ListPlaylistTest(string playlistName, int numberOfFiles)
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Playlists.Stored.ListPlaylist(playlistName));
|
||||
|
||||
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(numberOfFiles));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Playlist One", 5)]
|
||||
[InlineData("Playlist Two", 3)]
|
||||
[InlineData("_My Playlist", 5)]
|
||||
public async Task ListPlaylistInfoTest(string playlistName, int numberOfFiles)
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Playlists.Stored.ListPlaylistInfo(playlistName));
|
||||
|
||||
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(numberOfFiles));
|
||||
Assert.True(response.Response.Body.All(item => !string.IsNullOrEmpty(item.Artist)));
|
||||
Assert.True(response.Response.Body.All(item => !string.IsNullOrEmpty(item.Title)));
|
||||
Assert.True(response.Response.Body.All(item => !string.IsNullOrEmpty(item.Date)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListPlaylistsTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Playlists.Stored.ListPlaylists());
|
||||
|
||||
TestOutput.WriteLine($"ListPlaylistsTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(3));
|
||||
}
|
||||
}
|
||||
}
|
80
LibMpcTest/Tests/ReflectionCommandsTest.cs
Normal file
80
LibMpcTest/Tests/ReflectionCommandsTest.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using LibMpc;
|
||||
using System.Linq;
|
||||
|
||||
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));
|
||||
|
||||
// Different answer from MPD on Windows and on Linux, beacuse of Version.
|
||||
// Check some of the commands.
|
||||
Assert.True(response.Response.Body.Any(command => command.Equals("listall")));
|
||||
Assert.True(response.Response.Body.Any(command => command.Equals("outputs")));
|
||||
Assert.True(response.Response.Body.Any(command => command.Equals("pause")));
|
||||
Assert.True(response.Response.Body.Any(command => command.Equals("play")));
|
||||
Assert.True(response.Response.Body.Any(command => command.Equals("setvol")));
|
||||
Assert.True(response.Response.Body.Any(command => command.Equals("stop")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TagTypesTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Reflection.TagTypes());
|
||||
|
||||
TestOutput.WriteLine("TagTypesTest Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
Assert.True(response.Response.Body.Count().Equals(17));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UrlHandlersTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Reflection.UrlHandlers());
|
||||
|
||||
TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Body.Count()}) Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
// Different answer from MPD on Windows and on Linux.
|
||||
// Check some of the handlers.
|
||||
Assert.True(response.Response.Body.Any(handler => handler.Equals("http://")));
|
||||
Assert.True(response.Response.Body.Any(handler => handler.Equals("mms://")));
|
||||
Assert.True(response.Response.Body.Any(handler => handler.Equals("gopher://")));
|
||||
Assert.True(response.Response.Body.Any(handler => handler.Equals("rtp://")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DecodersTest()
|
||||
{
|
||||
var response = await Mpc.SendAsync(new Commands.Reflection.Decoders());
|
||||
|
||||
TestOutput.WriteLine($"DecodersTest (decoders: {response.Response.Body.Count()}) Result:");
|
||||
TestOutput.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
|
||||
|
||||
// Different answer from MPD on Windows and on Linux.
|
||||
// Check some of the decoders.
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Name.Equals("mad")));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("mp3"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/mpeg"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Name.Equals("flac")));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("flac"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/flac"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/x-flac"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Name.Equals("ffmpeg")));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("aac"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.Suffixes.Any(suffix => suffix.Equals("mpeg"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/aac"))));
|
||||
Assert.True(response.Response.Body.Any(decoder => decoder.MediaTypes.Any(mediaType => mediaType.Equals("audio/mpeg"))));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user