1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2025-07-01 08:47:36 +00:00

Restructured commands

This commit is contained in:
Kim Hugener-Ohlsen
2018-09-04 19:45:21 +02:00
parent 1f59105d4e
commit 393df7ca9a
95 changed files with 4733 additions and 1045 deletions

View File

@ -3,7 +3,6 @@ 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
@ -11,7 +10,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task ListAllTest()
{
var response = await Mpc.SendAsync(commands => commands.Database.ListAll());
var response = await Mpc.SendAsync(new Commands.Database.ListAllCommand());
TestOutput.WriteLine("ListAllTest Result:");
TestOutput.WriteLine(response);
@ -22,7 +21,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task FindGenreTest()
{
var response = await Mpc.SendAsync(commands => commands.Database.Find(MpdTags.Genre, "soundfx"));
var response = await Mpc.SendAsync(new Commands.Database.FindCommand(MpdTags.Genre, "soundfx"));
TestOutput.WriteLine("FindGenreTest Result:");
TestOutput.WriteLine(response);

View File

@ -9,10 +9,10 @@ namespace MpcNET.Test
[TestMethod]
public async Task DisableOutputTest()
{
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled);
var response = await Mpc.SendAsync(commands => commands.Output.DisableOutput(0));
var response = await Mpc.SendAsync(new Commands.Output.DisableOutputCommand(0));
TestOutput.WriteLine("DisableOutputTest Result:");
TestOutput.WriteLine(response);
@ -20,18 +20,18 @@ namespace MpcNET.Test
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(c => c.Output.Outputs());
responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled);
}
[TestMethod]
public async Task EnableOutputTest()
{
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
// By default should be disable from mpd.config
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled);
var response = await Mpc.SendAsync(commands => commands.Output.EnableOutput(1));
var response = await Mpc.SendAsync(new Commands.Output.EnableOutputCommand(1));
TestOutput.WriteLine("EnableOutputTest Result:");
TestOutput.WriteLine(response);
@ -39,17 +39,17 @@ namespace MpcNET.Test
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled);
}
[TestMethod]
public async Task ToggleOutputTest()
{
var responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
var responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(2)).IsEnabled);
var response = await Mpc.SendAsync(commands => commands.Output.ToggleOutput(2));
var response = await Mpc.SendAsync(new Commands.Output.ToggleOutputCommand(2));
TestOutput.WriteLine("ToggleOutputTest Result:");
TestOutput.WriteLine(response);
@ -57,14 +57,14 @@ namespace MpcNET.Test
Assert.IsTrue(response.Response.Content.Equals(string.Empty));
Assert.IsTrue(response.Response.Result.Status.Equals("OK"));
responseOutputs = await Mpc.SendAsync(commands => commands.Output.Outputs());
responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(2)).IsEnabled);
}
[TestMethod]
public async Task LisOutputsTest()
{
var response = await Mpc.SendAsync(commands => commands.Output.Outputs());
var response = await Mpc.SendAsync(new Commands.Output.OutputsCommand());
TestOutput.WriteLine("LisOutputsTest Result:");
TestOutput.WriteLine(response);

View File

@ -13,7 +13,7 @@
[DataRow("_My Playlist", 5)]
public async Task ListPlaylistTest(string playlistName, int numberOfFiles)
{
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetContent(playlistName));
var response = await Mpc.SendAsync(new Commands.Playlist.ListPlaylistCommand(playlistName));
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
TestOutput.WriteLine(response);
@ -27,7 +27,7 @@
[DataRow("_My Playlist", 5)]
public async Task ListPlaylistInfoTest(string playlistName, int numberOfFiles)
{
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetContentWithMetadata(playlistName));
var response = await Mpc.SendAsync(new Commands.Playlist.ListPlaylistInfoCommand(playlistName));
TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:");
TestOutput.WriteLine(response);
@ -41,7 +41,7 @@
[TestMethod]
public async Task ListPlaylistsTest()
{
var response = await Mpc.SendAsync(commands => commands.StoredPlaylist.GetAll());
var response = await Mpc.SendAsync(new Commands.Playlist.ListPlaylistsCommand());
TestOutput.WriteLine($"ListPlaylistsTest Result:");
TestOutput.WriteLine(response);
@ -117,57 +117,57 @@
private async Task Check_Empty_Queue()
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongsInfo());
var message = await Mpc.SendAsync(new Commands.Playlist.PlaylistCommand());
Assert.IsTrue(message.HasSuccessResponse());
Assert.IsFalse(message.Response.Content.Any());
}
private async Task Load_Playlist(string playlistName)
{
var message = await Mpc.SendAsync(commands => commands.StoredPlaylist.Load(playlistName));
var message = await Mpc.SendAsync(new Commands.Playlist.LoadCommand(playlistName));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Clear_Queue()
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.Clear());
var message = await Mpc.SendAsync(new Commands.Playlist.ClearCommand());
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Check_Queue_HasSongs(int nrOfSongs)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongsInfo());
var message = await Mpc.SendAsync(new Commands.Playlist.PlaylistCommand());
Assert.IsTrue(message.HasSuccessResponse());
Assert.IsTrue(message.Response.Content.Count() == nrOfSongs);
}
private async Task Add_Directory(string directory)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.AddDirectory(directory));
var message = await Mpc.SendAsync(new Commands.Playlist.AddCommand(directory));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Add_File(string file)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.AddSong(file));
var message = await Mpc.SendAsync(new Commands.Playlist.AddIdCommand(file));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Remove_Position(int position)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.RemoveSongByPosition(position));
var message = await Mpc.SendAsync(new Commands.Playlist.DeleteCommand(position));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task Remove_Id(int songId)
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.RemoveSongById(songId));
var message = await Mpc.SendAsync(new Commands.Playlist.DeleteIdCommand(songId));
Assert.IsTrue(message.HasSuccessResponse());
}
private async Task<int> Get_Song_Id()
{
var message = await Mpc.SendAsync(commands => commands.CurrentPlaylist.GetAllSongMetadata());
var message = await Mpc.SendAsync(new Commands.Playlist.PlaylistInfoCommand());
return message.Response.Content.Single().Id;
}
}

View File

@ -10,7 +10,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task CommandsTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.Commands());
var response = await Mpc.SendAsync(new Commands.Reflection.CommandsCommand());
TestOutput.WriteLine($"CommandsTest (commands: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
@ -28,7 +28,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task TagTypesTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.TagTypes());
var response = await Mpc.SendAsync(new Commands.Reflection.TagTypesCommand());
TestOutput.WriteLine("TagTypesTest Result:");
TestOutput.WriteLine(response);
@ -39,7 +39,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task UrlHandlersTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.UrlHandlers());
var response = await Mpc.SendAsync(new Commands.Reflection.UrlHandlersCommand());
TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);
@ -55,7 +55,7 @@ namespace MpcNET.Test
[TestMethod]
public async Task DecodersTest()
{
var response = await Mpc.SendAsync(commands => commands.Reflection.Decoders());
var response = await Mpc.SendAsync(new Commands.Reflection.DecodersCommand());
TestOutput.WriteLine($"DecodersTest (decoders: {response.Response.Content.Count()}) Result:");
TestOutput.WriteLine(response);