mirror of
https://github.com/ZetaKebab/MpcNET.git
synced 2025-07-01 08:47:36 +00:00
Output server log in test startup.
This commit is contained in:
@ -11,14 +11,19 @@ namespace LibMpcTest
|
||||
{
|
||||
public class LibMpcTest : IClassFixture<MpdServerTest>, IDisposable
|
||||
{
|
||||
private readonly MpdServerTest _server;
|
||||
private readonly ITestOutputHelper _output;
|
||||
private readonly Mpc _mpc;
|
||||
|
||||
public LibMpcTest(ITestOutputHelper output)
|
||||
public LibMpcTest(MpdServerTest server, ITestOutputHelper output)
|
||||
{
|
||||
_server = server;
|
||||
_output = output;
|
||||
|
||||
_mpc = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
|
||||
|
||||
Console.WriteLine(_server.LogError);
|
||||
|
||||
var connected = _mpc.ConnectAsync().GetAwaiter().GetResult();
|
||||
if (connected)
|
||||
{
|
||||
|
@ -4,10 +4,8 @@ using System.IO;
|
||||
|
||||
namespace LibMpcTest
|
||||
{
|
||||
internal class MpdServerTest : IDisposable
|
||||
public class MpdServerTest : IDisposable
|
||||
{
|
||||
private Process _process;
|
||||
|
||||
public MpdServerTest()
|
||||
{
|
||||
var serverPath = Path.Combine(AppContext.BaseDirectory, "Server");
|
||||
@ -17,7 +15,7 @@ namespace LibMpcTest
|
||||
var mpdExePath = Path.Combine(serverPath, "mpd.exe");
|
||||
var mpdConfPath = Path.Combine(serverPath, "mpd.conf");
|
||||
|
||||
_process = new Process
|
||||
Process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
@ -31,16 +29,19 @@ namespace LibMpcTest
|
||||
}
|
||||
};
|
||||
|
||||
_process.Start();
|
||||
var logOutput = _process.StandardOutput.ReadToEnd();
|
||||
var logError = _process.StandardError.ReadToEnd();
|
||||
Process.Start();
|
||||
LogOutput = Process.StandardOutput.ReadToEnd();
|
||||
LogError = Process.StandardError.ReadToEnd();
|
||||
}
|
||||
|
||||
public Process Process { get; }
|
||||
public string LogError { get; }
|
||||
public string LogOutput { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_process?.Kill();
|
||||
_process?.Dispose();
|
||||
_process = null;
|
||||
Process?.Kill();
|
||||
Process?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user