internal AppServer(int port, string appName, IDictionary <string, string> environmentVariables, string database) { _baseUrl = $"http://localhost:{port}"; _database = database; var appPath = $"{AppContext.BaseDirectory}../../../../Applications/{appName}"; _dllPath = $"{appPath}/bin/Debug/netcoreapp2.0/{appName}.dll"; _startInfo = new ProcessStartInfo { FileName = "dotnet", Arguments = $"exec {_dllPath} --urls {_baseUrl}", UseShellExecute = false, WorkingDirectory = appPath }; foreach (var kv in environmentVariables) { _startInfo.EnvironmentVariables[kv.Key] = kv.Value; } _startInfo.EnvironmentVariables["MYSQL__CLIENT__CONNECTIONSTRING"] = TestDatabaseSupport.ConnectionString(_database); }
public void Start() { if (!File.Exists(_dllPath)) { throw new InvalidOperationException($"File {_dllPath} does not exist. Run 'dotnet build' to rebuild the application."); } _process = Process.Start(_startInfo); WaitUntilReady(); new TestDatabaseSupport(TestDatabaseSupport.ConnectionString(_database)).TruncateAllTables(); }