src/Interlook.AspNetCore.Testing.IISExpress/IISExpressTestServerFixture.cs
/// <summary>
/// Starts the IIS Express server.
/// </summary>
/// <param name="throwExceptionOnError">if set to <c>true</c> an exception, that occurs during launching the server process
/// is thrown right after logging it to <see cref="System.Diagnostics.Debug"/> and <see cref="Console.Error"/>;
/// otherwise the exception is catched and the method will return <c>false</c>.</param>
/// <returns>
/// A value indicating, whether the server start has succeeded.
/// </returns>
/// <exception cref="InvalidOperationException">Error launching server. Only thrown if <paramref name="throwExceptionOnError"/> was <c>true</c>.</exception>
Starts the IIS Express server.
Starts the IIS Express server .
public bool StartServer(bool throwExceptionOnError = false)
        {
            _instance = IISExpress.Start(AppHostConfigFilePath, SiteName, AppPool, LauncherRelativePath);
            if (_instance is IISExpress.Process.Failed fail)
            {
                var errorText = new StringBuilder("Error starting IISExpress.")
                    .AppendLine()
                    .AppendLine($"Error: {fail.Exception.Message}")
                    .ToString();
                System.Diagnostics.Debug.WriteLine(errorText);
                Console.Error.WriteLine(errorText);
                return !throwExceptionOnError ? false : throw new InvalidOperationException("Error launching server.", fail.Exception);
            }
            else if (_instance is IISExpress.Process.Started)
            {
                return true;
            }
            else
            {
                if (throwExceptionOnError) throw new InvalidOperationException("Unknown error launching server. StartServer() returned unexpected object.");
                return false;
            }
        }
public bool StartServer ( bool throwExceptionOnError = false ) { _instance = IISExpress . Start ( AppHostConfigFilePath , SiteName , AppPool , LauncherRelativePath ) ; if ( _instance is IISExpress . Process . Failed fail ) { var errorText = new StringBuilder ( " " ) . AppendLine ( ) . AppendLine ( $" Error:  { fail . Exception . Message } " ) . ToString ( ) ; System . Diagnostics . Debug . WriteLine ( errorText ) ; Console . Error . WriteLine ( errorText ) ; return ! throwExceptionOnError ? false : throw new InvalidOperationException ( " " , fail . Exception ) ; } else if ( _instance is IISExpress . Process . Started ) { return true ; } else { if ( throwExceptionOnError ) throw new InvalidOperationException ( " " ) ; return false ; } }
Starts the IIS Express server.
Starts the IIS Express server .
A value indicating, whether the server start has succeeded.
A value indicating whether the server start has succeeded .
Error launching server. Only thrown if  was true
Error launching server . Only thrown if was true
throwExceptionOnError
bool
if set to true and ;
otherwise the exception is catched and the method will return false
if set to true and ; otherwise the exception is catched and the method will return false