public void ServerErrorTest() { var pipeName = IPCBuildResult.GetIPCPipeName(@"C:\One\One"); new Thread(() => { var server = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1); server.WaitForConnection(); var message = new IPCBuildResult { ServerError = "Return to your seat" }.ToArray(); server.Write(message, 0, message.Length); server.Close(); }).Start(); var engine = new Mock <IBuildEngine>(); var task = new RemoteBuildTask { ProjectDir = @"C:\One\One", BuildEngine = engine.Object }; Assert.False(task.Execute()); engine.Verify((e) => e.LogErrorEvent(It.Is <BuildErrorEventArgs>( (a) => a.Message == RemoteBuildTask.ServerErrorPrefix + "Return to your seat")), Times.Once); }
public void SuccessfulBuildTest() { var pipeName = IPCBuildResult.GetIPCPipeName(@"C:\One\One"); new Thread(() => { var server = new NamedPipeServerStream(pipeName, PipeDirection.Out, 1); server.WaitForConnection(); var message = new IPCBuildResult { ExitCode = 0 }.ToArray(); server.Write(message, 0, message.Length); server.Close(); }).Start(); var engine = new Mock <IBuildEngine>(); var task = new RemoteBuildTask { ProjectDir = @"C:\One\One", BuildEngine = engine.Object }; Assert.True(task.Execute()); engine.Verify((e) => e.LogErrorEvent(It.IsAny <BuildErrorEventArgs>()), Times.Never); }
public async Task RunServerLoopAsync() { while (!_serverLoopCts.Token.IsCancellationRequested) { try { using (var server = new NamedPipeServerStream(PipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous)) { await server.WaitForConnectionAsync(_serverLoopCts.Token).ConfigureAwait(false); var message = new IPCBuildResult { Skipped = true }.ToArray(); await server.WriteAsync(message, 0, message.Length); } } catch (OperationCanceledException) { /* Cancellation requested (_serverLoopCts) */ } }