private InProcessTestServer GetServer(Language defaultLanguage = Language.CSharp, Action <IServiceCollection> servicesSetup = null) { var newServer = InProcessTestServer.StartServer( $"http --default-kernel {defaultLanguage.LanguageName()} --http-port 4242", servicesSetup); _disposables.Add(newServer); return(newServer); }
private async Task <InProcessTestServer> GetServer(Language defaultLanguage = Language.CSharp, Action <IServiceCollection> servicesSetup = null, string command = "http", int port = 4242) { var newServer = await InProcessTestServer.StartServer( $"{command} --default-kernel {defaultLanguage.LanguageName()} --http-port {port}", servicesSetup); _disposables.Add(newServer); return(newServer); }
private InProcessTestServer GetServer(Language language) { if (_servers.TryGetValue(language, out var testServer)) { return(testServer); } var newServer = InProcessTestServer.StartServer($"http --default-kernel {language.LanguageName()}"); _servers.Add(language, newServer); return(newServer); }
public static InProcessTestServer StartServer(string args) { var server = new InProcessTestServer(); IWebHostBuilder builder = null; var parser = CommandLineParser.Create( server._serviceCollection, (startupOptions, invocationContext) => { builder = Program.ConstructWebHostBuilder( startupOptions, server._serviceCollection); }); parser.Invoke(args, server.Console); server._host = new TestServer(builder); server.Kernel = server._host.Services.GetRequiredService <IKernel>(); return(server); }
public static InProcessTestServer StartServer(string args, Action <IServiceCollection> servicesSetup = null) { var server = new InProcessTestServer(); IWebHostBuilder builder = null; var parser = CommandLineParser.Create( server._serviceCollection, (startupOptions, invocationContext) => { servicesSetup?.Invoke(server._serviceCollection); builder = Program.ConstructWebHostBuilder( startupOptions, server._serviceCollection); }); parser.Invoke(args, server.Console); server._host = new TestServer(builder); return(server); }
public static async Task <InProcessTestServer> StartServer(string args, Action <IServiceCollection> servicesSetup = null) { var server = new InProcessTestServer(); var completionSource = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously); var parser = CommandLineParser.Create( server._serviceCollection, (startupOptions, invocationContext) => { servicesSetup?.Invoke(server._serviceCollection); var builder = Program.ConstructWebHostBuilder( startupOptions, server._serviceCollection); server._host = new Lazy <TestServer>(() => new TestServer(builder)); completionSource.SetResult(true); }); await parser.InvokeAsync(args, new TestConsole()); await completionSource.Task; return(server); }
public HttpApiTests() { _server = InProcessTestServer.StartServer("http --default-kernel csharp"); }