Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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();

                    if (EqtTrace.IsInfoEnabled)
                    {
                        EqtTrace.Info("DesignModeClient.ProcessRequests: Processing Message: {0}", message);
                    }

                    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:
                    {
                        // Do not filter the Editor/IDE provided extensions by name
                        var extensionPaths = this.communicationManager.DeserializePayload <IEnumerable <string> >(message);
                        testRequestManager.InitializeExtensions(extensionPaths, skipExtensionFilters: true);
                        break;
                    }

                    case MessageType.StartDiscovery:
                    {
                        var discoveryPayload = this.dataSerializer.DeserializePayload <DiscoveryRequestPayload>(message);
                        this.StartDiscovery(discoveryPayload, testRequestManager);
                        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.CancelDiscovery:
                    {
                        testRequestManager.CancelDiscovery();
                        break;
                    }

                    case MessageType.CancelTestRun:
                    {
                        testRequestManager.CancelTestRun();
                        break;
                    }

                    case MessageType.AbortTestRun:
                    {
                        testRequestManager.AbortTestRun();
                        break;
                    }

                    case MessageType.CustomTestHostLaunchCallback:
                    {
                        this.onCustomTestHostLaunchAckReceived?.Invoke(message);
                        break;
                    }

                    case MessageType.EditorAttachDebuggerCallback:
                    {
                        this.onAttachDebuggerAckRecieved?.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);
        }
Exemplo n.º 3
0
        /// <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);
        }