Exemplo n.º 1
0
        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.HandleConnection(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();
            }
        }
Exemplo n.º 2
0
        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.HandleConnection();
                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();
            }
        }
Exemplo n.º 3
0
        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.HandleConnection().ConfigureAwait(false);

                Assert.Equal(CompletionReason.CompilationNotStarted, connectionData.CompletionReason);
                Assert.Null(connectionData.KeepAlive);
            }
            finally
            {
                clientStream.Close();
                serverStream.Close();
            }
        }