public async Task FindGenreTest() { var response = await Mpc.SendAsync(new Commands.Database.Find(MpdTags.Genre, "soundfx")); TestOutput.WriteLine("FindGenreTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Body.Count().Equals(7)); }
public async Task TagTypesTest() { var response = await Mpc.SendAsync(new Commands.Reflection.TagTypes()); TestOutput.WriteLine("TagTypesTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Body.Count().Equals(17)); }
public async Task ListPlaylistTest(string playlistName, int numberOfFiles) { var response = await Mpc.SendAsync(Commands.Playlists.Stored.GetContent(playlistName)); TestOutput.WriteLine($"ListPlaylistTest (playlistName: {playlistName}) Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Body.Count().Equals(numberOfFiles)); }
public async Task ListPlaylistsTest() { var response = await Mpc.SendAsync(Commands.Playlists.Stored.GetAll()); TestOutput.WriteLine($"ListPlaylistsTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Body.Count().Equals(3)); }
public async Task LisOutputsTest() { var response = await Mpc.SendAsync(new Commands.Output.OutputsCommand()); TestOutput.WriteLine("LisOutputsTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Content.Count().Equals(3)); }
public MpcMock() { var mpdEndpoint = new IPEndPoint(IPAddress.Loopback, 6600); this.Client = new MpcConnection(mpdEndpoint); Task.Run(async() => await this.Client.ConnectAsync()).Wait(); TestOutput.WriteLine($"Connected to MPD Version: {this.Client.Version}"); }
public async Task ListAllTest() { var response = await Mpc.SendAsync(new Commands.Database.ListAll()); TestOutput.WriteLine("ListAllTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Body.Count().Equals(7)); }
public MpcMock() { var mpdEndpoint = new IPEndPoint(IPAddress.Loopback, 6600); Client = new Mpc(mpdEndpoint); var connected = Task.Run(async() => await Client.ConnectAsync()).Result; TestOutput.WriteLine($"Connected to MPD : {connected}; Version: {Client.Version}"); }
public async Task ListPlaylistInfoTest(string playlistName, int numberOfFiles) { var response = await Mpc.SendAsync(Commands.Playlists.Stored.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))); }
public async Task UrlHandlersTest() { var response = await Mpc.SendAsync(new Commands.Reflection.UrlHandlers()); TestOutput.WriteLine($"UrlHandlersTest (handlers: {response.Response.Body.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://"))); }
public async Task CommandsTest() { var response = await Mpc.SendAsync(new Commands.Reflection.Commands()); TestOutput.WriteLine($"CommandsTest (commands: {response.Response.Body.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"))); }
public async Task DisableOutputTest() { 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(new Commands.Output.DisableOutputCommand(0)); TestOutput.WriteLine("DisableOutputTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Content.Equals(string.Empty)); Assert.IsTrue(response.Response.Result.Status.Equals("OK")); responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand()); Assert.IsFalse(responseOutputs.Response.Content.Single(output => output.Id.Equals(0)).IsEnabled); }
public async Task ToggleOutputTest() { var responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs()); Assert.IsTrue(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(response); Assert.IsTrue(response.Response.Body.Equals(string.Empty)); Assert.IsTrue(response.Response.State.Status.Equals("OK")); responseOutputs = await Mpc.SendAsync(new Commands.Output.Outputs()); Assert.IsFalse(responseOutputs.Response.Body.Single(output => output.Id.Equals(2)).IsEnabled); }
public async Task EnableOutputTest() { 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(new Commands.Output.EnableOutputCommand(1)); TestOutput.WriteLine("EnableOutputTest Result:"); TestOutput.WriteLine(response); Assert.IsTrue(response.Response.Content.Equals(string.Empty)); Assert.IsTrue(response.Response.Result.Status.Equals("OK")); responseOutputs = await Mpc.SendAsync(new Commands.Output.OutputsCommand()); Assert.IsTrue(responseOutputs.Response.Content.Single(output => output.Id.Equals(1)).IsEnabled); }
public async Task DecodersTest() { var response = await Mpc.SendAsync(new Commands.Reflection.Decoders()); TestOutput.WriteLine($"DecodersTest (decoders: {response.Response.Body.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")))); }
private void SendCommand(string command) { var netcat = new Process { StartInfo = new ProcessStartInfo { FileName = "/bin/bash", WorkingDirectory = "/bin/", Arguments = $"-c \"sudo {command}\"", UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, } }; netcat.Start(); netcat.WaitForExit(); TestOutput.WriteLine(command); TestOutput.WriteLine($"Output: {netcat.StandardOutput.ReadToEnd()}"); TestOutput.WriteLine($"Error: {netcat.StandardError.ReadToEnd()}"); }
public void Start() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { SendCommand("/usr/bin/pkill mpd"); } MpdConf.Create(Path.Combine(AppContext.BaseDirectory, "Server")); var server = GetServer(); Process = new Process { StartInfo = new ProcessStartInfo { FileName = server.FileName, WorkingDirectory = server.WorkingDirectory, Arguments = server.Arguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, } }; TestOutput.WriteLine($"Starting Server: {Process.StartInfo.FileName} {Process.StartInfo.Arguments}"); Process.Start(); TestOutput.WriteLine($"Output: {Process.StandardOutput.ReadToEnd()}"); TestOutput.WriteLine($"Error: {Process.StandardError.ReadToEnd()}"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { SendCommand("/bin/netstat -ntpl"); } }
private static async Task SendCommand <T>(IMpcCommand <T> command) { var response = await Mpc.SendAsync(command); TestOutput.WriteLine(response); }
private static async Task SendCommand(string command) { var response = await Mpc.SendAsync(new PassthroughCommand(command)); TestOutput.WriteLine(response); }
public void Dispose() { Process?.Kill(); Process?.Dispose(); TestOutput.WriteLine("Server Stopped."); }
public void Dispose() { this.Client?.DisconnectAsync().GetAwaiter().GetResult(); TestOutput.WriteLine($"Disconnected from MPD."); }