From 3c583ac5523eb33f6766526d0e1a3758f9930ef1 Mon Sep 17 00:00:00 2001 From: glucaci Date: Tue, 13 Dec 2016 13:12:51 +0100 Subject: [PATCH] Output server log in test startup. --- LibMpcTest/LibMpcTest.cs | 7 ++++++- LibMpcTest/MpdServerTest.cs | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/LibMpcTest/LibMpcTest.cs b/LibMpcTest/LibMpcTest.cs index cfd3775..8f85594 100644 --- a/LibMpcTest/LibMpcTest.cs +++ b/LibMpcTest/LibMpcTest.cs @@ -11,14 +11,19 @@ namespace LibMpcTest { public class LibMpcTest : IClassFixture, 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) { diff --git a/LibMpcTest/MpdServerTest.cs b/LibMpcTest/MpdServerTest.cs index fb54412..97543bb 100644 --- a/LibMpcTest/MpdServerTest.cs +++ b/LibMpcTest/MpdServerTest.cs @@ -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(); } } } \ No newline at end of file