private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITestRequestManager testRequestManager) { Task.Run( delegate { try { testRequestManager.ResetOptions(); testRequestManager.DiscoverTests(discoveryRequestPayload, new DesignModeTestEventsRegistrar(this), this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartDiscovery: " + ex); var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); var payload = new DiscoveryCompletePayload() { IsAborted = true, LastDiscoveredTests = null, TotalTests = -1 }; // Send run complete to translation layer this.communicationManager.SendMessage(MessageType.DiscoveryComplete, payload); } }); }
private void StartDiscovery(DiscoveryRequestPayload discoveryRequestPayload, ITestRequestManager testRequestManager) { Task.Run( delegate { try { testRequestManager.ResetOptions(); testRequestManager.DiscoverTests(discoveryRequestPayload, new DesignModeTestEventsRegistrar(this), this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartDiscovery: " + ex); // If there is an exception during test discovery request creation or some time during the process // In such cases, TestPlatform will never send a DiscoveryComplete event and IDE need to be sent a discovery complete message // We need recoverability in translationlayer-designmode scenarios var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); var payload = new DiscoveryCompletePayload() { IsAborted = true, LastDiscoveredTests = null, TotalTests = -1 }; // Send run complete to translation layer this.communicationManager.SendMessage(MessageType.DiscoveryComplete, payload); } }); }
/// <summary> /// Process Requests from the IDE /// </summary> /// <param name="testRequestManager"> /// The test Request Manager. /// </param> private void ProcessRequests(ITestRequestManager testRequestManager) { var isSessionEnd = false; do { try { var message = this.communicationManager.ReceiveMessage(); EqtTrace.Info("DesignModeClient: Processing Message of message type: {0}", message.MessageType); switch (message.MessageType) { case MessageType.VersionCheck: { // At this point, we cannot add stuff to object model like "ProtocolVersionMessage" // as that cannot be acessed from testwindow which still uses TP-V1 // we are sending a version number as an integer for now // TODO: Find a better way without breaking TW which using TP-V1 var payload = 1; this.communicationManager.SendMessage(MessageType.VersionCheck, payload); break; } case MessageType.ExtensionsInitialize: { var extensionPaths = this.communicationManager.DeserializePayload <IEnumerable <string> >(message); testRequestManager.InitializeExtensions(extensionPaths); break; } case MessageType.StartDiscovery: { var discoveryPayload = message.Payload.ToObject <DiscoveryRequestPayload>(); testRequestManager.DiscoverTests(discoveryPayload, new DesignModeTestEventsRegistrar(this)); break; } case MessageType.GetTestRunnerProcessStartInfoForRunAll: case MessageType.GetTestRunnerProcessStartInfoForRunSelected: { var testRunPayload = this.communicationManager.DeserializePayload <TestRunRequestPayload>( message); this.StartTestRun(testRunPayload, testRequestManager, skipTestHostLaunch: true); break; } case MessageType.TestRunAllSourcesWithDefaultHost: case MessageType.TestRunSelectedTestCasesDefaultHost: { var testRunPayload = this.communicationManager.DeserializePayload <TestRunRequestPayload>( message); this.StartTestRun(testRunPayload, testRequestManager, skipTestHostLaunch: false); break; } case MessageType.CancelTestRun: { testRequestManager.CancelTestRun(); break; } case MessageType.AbortTestRun: { testRequestManager.AbortTestRun(); break; } case MessageType.CustomTestHostLaunchCallback: { this.onAckMessageReceived?.Invoke(message); break; } case MessageType.SessionEnd: { EqtTrace.Info("DesignModeClient: Session End message received from server. Closing the connection."); isSessionEnd = true; this.Dispose(); break; } default: { EqtTrace.Info("DesignModeClient: Invalid Message received: {0}", message); break; } } } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Error processing request: {0}", ex); isSessionEnd = true; this.Dispose(); } }while (!isSessionEnd); }
/// <summary> /// Process Requests from the IDE /// </summary> /// <param name="testRequestManager"> /// The test Request Manager. /// </param> private void ProcessRequests(ITestRequestManager testRequestManager) { var isSessionEnd = false; do { try { var message = this.communicationManager.ReceiveMessage(); EqtTrace.Info("DesignModeClient: Processing Message of message type: {0}", message.MessageType); switch (message.MessageType) { case MessageType.VersionCheck: { var version = this.dataSerializer.DeserializePayload <int>(message); this.protocolConfig.Version = Math.Min(version, this.protocolConfig.Version); this.communicationManager.SendMessage(MessageType.VersionCheck, this.protocolConfig.Version); break; } case MessageType.ExtensionsInitialize: { var extensionPaths = this.communicationManager.DeserializePayload <IEnumerable <string> >(message); testRequestManager.InitializeExtensions(extensionPaths); break; } case MessageType.StartDiscovery: { var discoveryPayload = message.Payload.ToObject <DiscoveryRequestPayload>(); testRequestManager.DiscoverTests(discoveryPayload, new DesignModeTestEventsRegistrar(this), this.protocolConfig); break; } case MessageType.GetTestRunnerProcessStartInfoForRunAll: case MessageType.GetTestRunnerProcessStartInfoForRunSelected: { var testRunPayload = this.communicationManager.DeserializePayload <TestRunRequestPayload>( message); this.StartTestRun(testRunPayload, testRequestManager, skipTestHostLaunch: true); break; } case MessageType.TestRunAllSourcesWithDefaultHost: case MessageType.TestRunSelectedTestCasesDefaultHost: { var testRunPayload = this.communicationManager.DeserializePayload <TestRunRequestPayload>( message); this.StartTestRun(testRunPayload, testRequestManager, skipTestHostLaunch: false); break; } case MessageType.CancelTestRun: { testRequestManager.CancelTestRun(); break; } case MessageType.AbortTestRun: { testRequestManager.AbortTestRun(); break; } case MessageType.CustomTestHostLaunchCallback: { this.onAckMessageReceived?.Invoke(message); break; } case MessageType.SessionEnd: { EqtTrace.Info("DesignModeClient: Session End message received from server. Closing the connection."); isSessionEnd = true; this.Dispose(); break; } default: { EqtTrace.Info("DesignModeClient: Invalid Message received: {0}", message); break; } } } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Error processing request: {0}", ex); isSessionEnd = true; this.Dispose(); } }while (!isSessionEnd); }