private void SaveTraceReport(TestTraceMessage report)
 {
     if (report.Contents != null)
     {
         string fileName       = this.Configuration.AssemblyToBeAnalyzed;
         string targetDir      = Path.GetDirectoryName(fileName);
         string outputDir      = Path.Combine(targetDir, "Output", Path.GetFileName(fileName), "CoyoteOutput");
         string remoteFileName = Path.GetFileName(report.FileName);
         string localTraceFile = Path.Combine(outputDir, remoteFileName);
         File.WriteAllText(localTraceFile, report.Contents);
         Console.WriteLine($"... Saved trace report: {localTraceFile}");
     }
     else
     {
         // tests ran locally so the file name is good!
         Console.WriteLine($"... See trace report: {report.FileName}");
     }
 }
        private async void HandleClientAsync(SmartSocketClient client)
        {
            while (client.IsConnected)
            {
                SocketMessage e = await client.ReceiveAsync();

                if (e != null)
                {
                    this.LastMessageTime = Environment.TickCount;
                    uint processId = 0;

                    if (e.Id == SmartSocketClient.ConnectedMessageId)
                    {
                        lock (this.SchedulerLock)
                        {
                            this.TestProcessesConnected++;
                            this.TestingProcessChannels.Add(e.Sender, client);
                        }
                    }
                    else if (e is BugFoundMessage)
                    {
                        BugFoundMessage bug = (BugFoundMessage)e;
                        processId = bug.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        if (this.IsVerbose)
                        {
                            Console.WriteLine($"... Bug report received from '{bug.Sender}'");
                        }

                        this.NotifyBugFound(processId);
                    }
                    else if (e is TestReportMessage)
                    {
                        TestReportMessage report = (TestReportMessage)e;
                        processId = report.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        if (this.IsVerbose)
                        {
                            Console.WriteLine($"... Test report received from '{report.Sender}'");
                        }

                        this.SetTestReport(report.TestReport, report.ProcessId);
                    }
                    else if (e is TestTraceMessage)
                    {
                        TestTraceMessage report = (TestTraceMessage)e;
                        processId = report.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        this.SaveTraceReport(report);
                    }
                    else if (e is TestProgressMessage)
                    {
                        TestProgressMessage progress = (TestProgressMessage)e;
                        processId = progress.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        // todo: do something fun with progress info.
                    }
                }
            }
        }