public async Task NoCompilationsProcessShutdown() { var host = new TestableCompilerServerHost(runCompilation: delegate { // We should never get here. Assert.False(true); throw null; }); var(clientStream, serverStream) = await CreateNamedPipePair().ConfigureAwait(false); try { var connection = new NamedPipeClientConnection(host, "identifier", serverStream); await BuildRequest.CreateShutdown().WriteAsync(clientStream).ConfigureAwait(false); var connectionData = await connection.HandleConnectionAsync(allowCompilationRequests : false).ConfigureAwait(false); Assert.Equal(CompletionReason.ClientShutdownRequest, connectionData.CompletionReason); Assert.Null(connectionData.KeepAlive); var response = await BuildResponse.ReadAsync(clientStream); Assert.Equal(BuildResponse.ResponseType.Shutdown, response.Type); } finally { clientStream.Close(); serverStream.Close(); } }
public async Task WriteError() { using var compileMre = new ManualResetEvent(initialState: false); using var closedStreamMre = new ManualResetEvent(initialState: false); var host = new TestableCompilerServerHost(runCompilation: delegate { compileMre.Set(); closedStreamMre.WaitOne(); return(s_emptyBuildResponse); }); var(clientStream, serverStream) = await CreateNamedPipePair().ConfigureAwait(false); try { var connection = new NamedPipeClientConnection(host, "identifier", serverStream); await s_emptyCSharpBuildRequest.WriteAsync(clientStream).ConfigureAwait(false); var connectionTask = connection.HandleConnectionAsync(); await compileMre.WaitOneAsync().ConfigureAwait(false); clientStream.Close(); closedStreamMre.Set(); var connectionData = await connectionTask.ConfigureAwait(false); Assert.Equal(CompletionReason.ClientDisconnect, connectionData.CompletionReason); Assert.Null(connectionData.KeepAlive); } finally { clientStream.Close(); serverStream.Close(); } }
public async Task ReadFailure() { var host = new TestableCompilerServerHost(runCompilation: delegate { return(s_emptyBuildResponse); }); var(clientStream, serverStream) = await CreateNamedPipePair().ConfigureAwait(false); try { var connection = new NamedPipeClientConnection(host, "identifier", serverStream); clientStream.Close(); var connectionData = await connection.HandleConnectionAsync().ConfigureAwait(false); Assert.Equal(CompletionReason.CompilationNotStarted, connectionData.CompletionReason); Assert.Null(connectionData.KeepAlive); } finally { clientStream.Close(); serverStream.Close(); } }