private static void ExpectStartupException(string key, string value, Action <StartupException> assert)
        {
            var created = false;

            try
            {
                var elasticsearchProcessTester = new ElasticsearchProcessTester(s => s
                                                                                .Elasticsearch(e => e
                                                                                               .EsHomeMachineVariable(DefaultEsHome)
                                                                                               .EnvironmentVariables(new kv {
                    { key, value }
                }))
                                                                                .Java(j => j.JavaHomeMachineVariable(DefaultJavaHome))
                                                                                .ConsoleSession(ConsoleSession.StartedSession)
                                                                                .FileSystem(fs => s.AddJavaExe(s.AddElasticsearchLibs(fs, null)))
                                                                                );
                created = true;
            }
            catch (Exception e)
            {
                var se = e as StartupException;
                if (se == null)
                {
                    throw new Exception("Exception was thrown but not of type StartupException see InnerException", e);
                }
                assert(se);
            }
            if (created)
            {
                throw new Exception($"Process tester expected elasticsearch.exe to throw an exception for {key}");
            }
        }
        private static kv Start(Func <MockElasticsearchEnvironmentStateProvider, MockElasticsearchEnvironmentStateProvider> setter = null)
        {
            setter = setter ?? (e => e);
            var elasticsearchProcessTester = new ElasticsearchProcessTester(s => s
                                                                            .Elasticsearch(e => setter(e.EsHomeMachineVariable(DefaultEsHome)))
                                                                            .Java(j => j.LegacyJavaHomeMachineVariable(DefaultJavaHome).EsJavaHomeMachineVariable(DefaultJavaHome))
                                                                            .ConsoleSession(ConsoleSession.StartedSession)
                                                                            .FileSystem(fs => s.AddJavaExe(s.AddElasticsearchLibs(fs, null)))
                                                                            );

            elasticsearchProcessTester.Process.Start();
            return(elasticsearchProcessTester.ObservableProcess.ProcessVariables);
        }