@ -1,15 +1,11 @@
using System ;
using System ;
using System.Collections.Generic ;
using System.Diagnostics ;
using System.Diagnostics ;
using System.IO ;
using System.IO ;
using System.Threading ;
using System.Threading ;
using System.Xml ;
using System.Xml.Linq ;
using System.Xml.Linq ;
using System.Xml.XPath ;
using NLog ;
using NLog ;
using NUnit.Framework ;
using NUnit.Framework ;
using NzbDrone.Common.EnvironmentInfo ;
using NzbDrone.Common.EnvironmentInfo ;
using NzbDrone.Common.Extensions ;
using NzbDrone.Common.Processes ;
using NzbDrone.Common.Processes ;
using NzbDrone.Core.Configuration ;
using NzbDrone.Core.Configuration ;
using RestSharp ;
using RestSharp ;
@ -21,7 +17,6 @@ namespace NzbDrone.Test.Common
private readonly IProcessProvider _processProvider ;
private readonly IProcessProvider _processProvider ;
private readonly IRestClient _restClient ;
private readonly IRestClient _restClient ;
private Process _nzbDroneProcess ;
private Process _nzbDroneProcess ;
private List < string > _startupLog ;
public string AppData { get ; private set ; }
public string AppData { get ; private set ; }
public string ApiKey { get ; private set ; }
public string ApiKey { get ; private set ; }
@ -41,7 +36,6 @@ namespace NzbDrone.Test.Common
var lidarrConsoleExe = OsInfo . IsWindows ? "Lidarr.Console.exe" : "Lidarr.exe" ;
var lidarrConsoleExe = OsInfo . IsWindows ? "Lidarr.Console.exe" : "Lidarr.exe" ;
_startupLog = new List < string > ( ) ;
if ( BuildInfo . IsDebug )
if ( BuildInfo . IsDebug )
{
{
Start ( Path . Combine ( TestContext . CurrentContext . TestDirectory , ".." , "_output" , "Lidarr.Console.exe" ) ) ;
Start ( Path . Combine ( TestContext . CurrentContext . TestDirectory , ".." , "_output" , "Lidarr.Console.exe" ) ) ;
@ -57,10 +51,9 @@ namespace NzbDrone.Test.Common
if ( _nzbDroneProcess . HasExited )
if ( _nzbDroneProcess . HasExited )
{
{
Console . WriteLine ( "Lidarr has exited unexpectedly" ) ;
TestContext. Progress . WriteLine ( "Lidarr has exited unexpectedly" ) ;
Thread . Sleep ( 2000 ) ;
Thread . Sleep ( 2000 ) ;
var output = _startupLog . Join ( Environment . NewLine ) ;
Assert . Fail ( "Process has exited: ExitCode={0}" , _nzbDroneProcess . ExitCode ) ;
Assert . Fail ( "Process has exited: ExitCode={0} Output={1}" , _nzbDroneProcess . ExitCode , output ) ;
}
}
var request = new RestRequest ( "system/status" ) ;
var request = new RestRequest ( "system/status" ) ;
@ -71,12 +64,11 @@ namespace NzbDrone.Test.Common
if ( statusCall . ResponseStatus = = ResponseStatus . Completed )
if ( statusCall . ResponseStatus = = ResponseStatus . Completed )
{
{
_startupLog = null ;
TestContext . Progress . WriteLine ( "Lidarr is started. Running Tests" ) ;
Console . WriteLine ( "Lidarr is started. Running Tests" ) ;
return ;
return ;
}
}
Console . WriteLine ( "Waiting for Lidarr to start. Response Status : {0} [{1}] {2}" , statusCall . ResponseStatus , statusCall . StatusDescription , statusCall . ErrorException . Message ) ;
TestContext. Progress . WriteLine ( "Waiting for Lidarr to start. Response Status : {0} [{1}] {2}" , statusCall . ResponseStatus , statusCall . StatusDescription , statusCall . ErrorException . Message ) ;
Thread . Sleep ( 500 ) ;
Thread . Sleep ( 500 ) ;
}
}
@ -104,7 +96,7 @@ namespace NzbDrone.Test.Common
private void Start ( string outputNzbdroneConsoleExe )
private void Start ( string outputNzbdroneConsoleExe )
{
{
Console . WriteLine ( "Starting instance from {0}" , outputNzbdroneConsoleExe ) ;
TestContext. Progress . WriteLine ( "Starting instance from {0}" , outputNzbdroneConsoleExe ) ;
var args = "-nobrowser -data=\"" + AppData + "\"" ;
var args = "-nobrowser -data=\"" + AppData + "\"" ;
_nzbDroneProcess = _processProvider . Start ( outputNzbdroneConsoleExe , args , null , OnOutputDataReceived , OnOutputDataReceived ) ;
_nzbDroneProcess = _processProvider . Start ( outputNzbdroneConsoleExe , args , null , OnOutputDataReceived , OnOutputDataReceived ) ;
@ -113,12 +105,7 @@ namespace NzbDrone.Test.Common
private void OnOutputDataReceived ( string data )
private void OnOutputDataReceived ( string data )
{
{
Console . WriteLine ( data ) ;
TestContext . Progress . WriteLine ( " > " + data ) ;
if ( _startupLog ! = null )
{
_startupLog . Add ( data ) ;
}
if ( data . Contains ( "Press enter to exit" ) )
if ( data . Contains ( "Press enter to exit" ) )
{
{