1
0
mirror of https://github.com/ZetaKebab/MpcNET.git synced 2024-09-16 05:30:09 +00:00
MpcNET/Sources/MpcNET.Test/LibMpcTest.cs

63 lines
1.6 KiB
C#
Raw Normal View History

2018-05-18 13:14:20 +00:00
namespace MpcNET.Test
2017-04-12 09:21:29 +00:00
{
2018-05-18 13:14:20 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
2017-04-12 09:21:29 +00:00
[TestClass]
public partial class LibMpcTest
{
private static MpdMock _mpdMock;
[ClassInitialize]
public static void Init(TestContext context)
{
_mpdMock = new MpdMock();
_mpdMock.Start();
Mpc = new MpcMock().Client;
}
[ClassCleanup]
public static void Cleanup()
{
_mpdMock.Dispose();
}
2018-05-18 13:14:20 +00:00
internal static MpcConnection Mpc { get; private set; }
private static async Task SendCommand(string command)
{
2018-09-04 17:45:21 +00:00
var response = await Mpc.SendAsync(new PassthroughCommand(command));
TestOutput.WriteLine(response);
}
private static async Task SendCommand<T>(IMpcCommand<T> command)
{
2018-09-04 17:45:21 +00:00
var response = await Mpc.SendAsync(command);
TestOutput.WriteLine(response);
}
private class PassthroughCommand : IMpcCommand<IList<string>>
{
2018-05-18 13:14:20 +00:00
private readonly string command;
public PassthroughCommand(string command)
{
2018-05-18 13:14:20 +00:00
this.command = command;
}
2018-05-18 13:14:20 +00:00
public string Serialize()
{
return this.command;
}
2021-10-03 15:53:58 +00:00
public IList<string> Deserialize(SerializedResponse response)
{
2021-10-03 15:53:58 +00:00
var result = response.ResponseValues.Select(atrb => $"{atrb.Key}: {atrb.Value}").ToList();
return result;
}
}
2017-04-12 09:21:29 +00:00
}
}