internal UseVsixExtensionsArgumentExecutor(CommandLineOptions commandLineOptions, ITestRequestManager testRequestManager, IVSExtensionManager extensionManager, IOutput output) { this.commandLineOptions = commandLineOptions; this.testRequestManager = testRequestManager; this.extensionManager = extensionManager; this.output = output; }
/// <summary> /// Default constructor. /// </summary> /// <param name="options"> /// The options. /// </param> public ListFullyQualifiedTestsArgumentExecutor( CommandLineOptions options, IRunSettingsProvider runSettingsProvider, ITestRequestManager testRequestManager) : this(options, runSettingsProvider, testRequestManager, ConsoleOutput.Instance) { }
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); } }); }
private void StartTestRun(TestRunRequestPayload testRunPayload, ITestRequestManager testRequestManager, bool skipTestHostLaunch) { Task.Run( delegate { try { testRequestManager.ResetOptions(); var customLauncher = skipTestHostLaunch ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(this, testRunPayload) : null; testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); var runCompletePayload = new TestRunCompletePayload() { TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, TimeSpan.MinValue), LastRunTests = null }; // Send run complete to translation layer this.communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); } }); }
private RunSpecificTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager) { var runSettingsProvider = new TestableRunSettingsProvider(); runSettingsProvider.AddDefaultRunSettings(); return(new RunSpecificTestsArgumentExecutor(CommandLineOptions.Instance, runSettingsProvider, testRequestManager, this.mockOutput.Object)); }
private void StartTestRun(TestRunRequestPayload testRunPayload, ITestRequestManager testRequestManager, bool skipTestHostLaunch) { Task.Run( delegate { try { testRequestManager.ResetOptions(); var customLauncher = skipTestHostLaunch ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(this, testRunPayload) : null; testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); // If there is an exception during test run request creation or some time during the process // In such cases, TestPlatform will never send a TestRunComplete event and IDE need to be sent a run 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 runCompletePayload = new TestRunCompletePayload() { TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, TimeSpan.MinValue), LastRunTests = null }; // Send run complete to translation layer this.communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); } }); }
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); } }); }
/// <summary> /// Creates a client and waits for server to accept connection asynchronously /// </summary> /// <param name="port"> /// Port number to connect /// </param> /// <param name="testRequestManager"> /// The test Request Manager. /// </param> public void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager) { EqtTrace.Info("Trying to connect to server on port : {0}", port); this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); var connectionTimeoutInSecs = EnvironmentHelper.GetConnectionTimeout(); // Wait for the connection to the server and listen for requests. if (this.communicationManager.WaitForServerConnection(connectionTimeoutInSecs * 1000)) { this.communicationManager.SendMessage(MessageType.SessionConnected); this.ProcessRequests(testRequestManager); } else { EqtTrace.Error("DesignModeClient : ConnectToClientAndProcessRequests : Client timed out while connecting to the server."); this.Dispose(); throw new TimeoutException( string.Format( CultureInfo.CurrentUICulture, CommunicationUtilitiesResources.ConnectionTimeoutErrorMessage, CoreUtilitiesConstants.VstestConsoleProcessName, "translation layer", connectionTimeoutInSecs, EnvironmentHelper.VstestConnectionTimeout) ); } }
/// <summary> /// For Unit testing only /// </summary> internal PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager, Func <int, IDesignModeClient> designModeInitializer) { Contract.Requires(options != null); this.commandLineOptions = options; this.testRequestManager = testRequestManager; this.designModeInitializer = designModeInitializer; }
public void TestInit() { this.mockTestPlatform = new Mock <ITestPlatform>(); this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>(); this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, this.mockTestPlatform.Object, TestLoggerManager.Instance, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object); }
public void RunTestsWithSourcesShouldCallTestPlatformAndSucceed() { var payload = new TestRunRequestPayload() { Sources = new List <string>() { "a", "b" } }; var createRunRequestCalled = 0; TestRunCriteria observedCriteria = null; var mockRunRequest = new Mock <ITestRunRequest>(); this.mockTestPlatform.Setup(mt => mt.CreateTestRunRequest(It.IsAny <TestRunCriteria>())).Callback <TestRunCriteria>( (runCriteria) => { createRunRequestCalled++; observedCriteria = runCriteria; }).Returns(mockRunRequest.Object); var mockRunEventsRegistrar = new Mock <ITestRunEventsRegistrar>(); var mockCustomlauncher = new Mock <ITestHostLauncher>(); string testCaseFilterValue = "TestFilter"; CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, this.mockTestPlatform.Object, TestLoggerManager.Instance, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object); var success = this.testRequestManager.RunTests(payload, mockCustomlauncher.Object, mockRunEventsRegistrar.Object); Assert.IsTrue(success, "RunTests call must succeed"); Assert.AreEqual(testCaseFilterValue, observedCriteria.TestCaseFilter, "TestCaseFilter must be set"); Assert.AreEqual(createRunRequestCalled, 1, "CreateRunRequest must be invoked only once."); Assert.AreEqual(2, observedCriteria.Sources.Count(), "All Sources must be used for discovery request"); Assert.AreEqual("a", observedCriteria.Sources.First(), "First Source in list is incorrect"); Assert.AreEqual("b", observedCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); // Check for the default value for the frequency Assert.AreEqual(10, observedCriteria.FrequencyOfRunStatsChangeEvent); mockRunEventsRegistrar.Verify(md => md.RegisterTestRunEvents(It.IsAny <ITestRunRequest>()), Times.Once); mockRunEventsRegistrar.Verify(md => md.UnregisterTestRunEvents(It.IsAny <ITestRunRequest>()), Times.Once); mockRunRequest.Verify(md => md.ExecuteAsync(), Times.Once); mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStart(), Times.Once); mockTestPlatformEventSource.Verify(mt => mt.ExecutionRequestStop(), Times.Once); }
public void DiscoverTestsShouldCallTestPlatformAndSucceed() { var payload = new DiscoveryRequestPayload() { Sources = new List <string>() { "a", "b" } }; var createDiscoveryRequestCalled = 0; DiscoveryCriteria actualDiscoveryCriteria = null; var mockDiscoveryRequest = new Mock <IDiscoveryRequest>(); this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny <IRequestData>(), It.IsAny <DiscoveryCriteria>())).Callback( (IRequestData requestData, DiscoveryCriteria discoveryCriteria) => { createDiscoveryRequestCalled++; actualDiscoveryCriteria = discoveryCriteria; }).Returns(mockDiscoveryRequest.Object); var mockDiscoveryRegistrar = new Mock <ITestDiscoveryEventsRegistrar>(); string testCaseFilterValue = "TestFilter"; CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, this.mockTestPlatform.Object, TestLoggerManager.Instance, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object); var success = this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, this.protocolConfig); Assert.IsTrue(success, "DiscoverTests call must succeed"); Assert.AreEqual(testCaseFilterValue, actualDiscoveryCriteria.TestCaseFilter, "TestCaseFilter must be set"); Assert.AreEqual(createDiscoveryRequestCalled, 1, "CreateDiscoveryRequest must be invoked only once."); Assert.AreEqual(2, actualDiscoveryCriteria.Sources.Count(), "All Sources must be used for discovery request"); Assert.AreEqual("a", actualDiscoveryCriteria.Sources.First(), "First Source in list is incorrect"); Assert.AreEqual("b", actualDiscoveryCriteria.Sources.ElementAt(1), "Second Source in list is incorrect"); // Default frequency is set to 10, unless specified in runsettings. Assert.AreEqual(10, actualDiscoveryCriteria.FrequencyOfDiscoveredTestsEvent); mockDiscoveryRegistrar.Verify(md => md.RegisterDiscoveryEvents(It.IsAny <IDiscoveryRequest>()), Times.Once); mockDiscoveryRegistrar.Verify(md => md.UnregisterDiscoveryEvents(It.IsAny <IDiscoveryRequest>()), Times.Once); mockDiscoveryRequest.Verify(md => md.DiscoverAsync(), Times.Once); mockTestPlatformEventSource.Verify(mt => mt.DiscoveryRequestStart(), Times.Once); mockTestPlatformEventSource.Verify(mt => mt.DiscoveryRequestStop(), Times.Once); }
private static RunTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager) { var runSettingsProvider = new TestableRunSettingsProvider(); runSettingsProvider.AddDefaultRunSettings(); var executor = new RunTestsArgumentExecutor( CommandLineOptions.Instance, runSettingsProvider, testRequestManager); return(executor); }
private static ListFullyQualifiedTestsArgumentExecutor GetExecutor(ITestRequestManager testRequestManager, IOutput output) { var runSettingsProvider = new TestableRunSettingsProvider(); runSettingsProvider.AddDefaultRunSettings(); var listFullyQualifiedTestsArgumentExecutor = new ListFullyQualifiedTestsArgumentExecutor( CommandLineOptions.Instance, runSettingsProvider, testRequestManager, output ?? ConsoleOutput.Instance); return(listFullyQualifiedTestsArgumentExecutor); }
/// <summary> /// Default constructor. /// </summary> public RunTestsArgumentExecutor( CommandLineOptions commandLineOptions, IRunSettingsProvider runSettingsProvider, ITestRequestManager testRequestManager, IOutput output) { Contract.Requires(commandLineOptions != null); this.commandLineOptions = commandLineOptions; this.runSettingsManager = runSettingsProvider; this.testRequestManager = testRequestManager; this.output = output; this.testRunEventsRegistrar = new TestRunRequestEventsRegistrar(this.output); }
/// <summary> /// Default constructor. /// </summary> /// <param name="options"> /// The options. /// </param> internal ListTestsArgumentExecutor( CommandLineOptions options, IRunSettingsProvider runSettingsProvider, ITestRequestManager testRequestManager, IOutput output) { Contract.Requires(options != null); this.commandLineOptions = options; this.output = output; this.testRequestManager = testRequestManager; this.runSettingsManager = runSettingsProvider; this.discoveryEventsRegistrar = new DiscoveryEventsRegistrar(output); }
/// <summary> /// Default constructor. /// </summary> public RunSpecificTestsArgumentExecutor( CommandLineOptions options, IRunSettingsProvider runSettingsProvider, ITestRequestManager testRequestManager) { Contract.Requires(options != null); Contract.Requires(testRequestManager != null); this.commandLineOptions = options; this.testRequestManager = testRequestManager; this.runSettingsManager = runSettingsProvider; this.output = ConsoleOutput.Instance; this.discoveryEventsRegistrar = new DiscoveryEventsRegistrar(this.discoveryRequest_OnDiscoveredTests); }
/// <summary> /// Creates a client and waits for server to accept connection asynchronously /// </summary> /// <param name="port"> /// Port number to connect /// </param> /// <param name="testRequestManager"> /// The test Request Manager. /// </param> public void ConnectToClientAndProcessRequests(int port, ITestRequestManager testRequestManager) { EqtTrace.Info("Trying to connect to server on port : {0}", port); this.communicationManager.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)); // Wait for the connection to the server and listen for requests. if (this.communicationManager.WaitForServerConnection(ClientListenTimeOut)) { this.communicationManager.SendMessage(MessageType.SessionConnected); this.ProcessRequests(testRequestManager); } else { EqtTrace.Info("Client timed out while connecting to the server."); this.Dispose(); throw new TimeoutException(); } }
public TestRequestManagerTests() { this.mockLoggerEvents = new DummyLoggerEvents(TestSessionMessageLogger.Instance); this.mockLoggerManager = new DummyTestLoggerManager(this.mockLoggerEvents); this.commandLineOptions = new DummyCommandLineOptions(); this.mockTestPlatform = new Mock <ITestPlatform>(); this.mockDiscoveryRequest = new Mock <IDiscoveryRequest>(); this.mockRunRequest = new Mock <ITestRunRequest>(); this.mockTestPlatformEventSource = new Mock <ITestPlatformEventSource>(); var testRunResultAggregator = new DummyTestRunResultAggregator(); this.testRequestManager = new TestRequestManager(this.commandLineOptions, this.mockTestPlatform.Object, mockLoggerManager, testRunResultAggregator, mockTestPlatformEventSource.Object); this.mockTestPlatform.Setup(tp => tp.CreateDiscoveryRequest(It.IsAny <DiscoveryCriteria>(), It.IsAny <ProtocolConfig>())) .Returns(this.mockDiscoveryRequest.Object); this.mockTestPlatform.Setup(tp => tp.CreateTestRunRequest(It.IsAny <TestRunCriteria>(), It.IsAny <ProtocolConfig>())) .Returns(this.mockRunRequest.Object); }
private void StartTestRun(TestRunRequestPayload testRunPayload, ITestRequestManager testRequestManager, bool shouldLaunchTesthost) { Task.Run( () => { try { testRequestManager.ResetOptions(); // We must avoid re-launching the test host if the test run payload already // contains test session info. Test session info being present is an indicative // of an already running test host spawned by a start test session call. var customLauncher = shouldLaunchTesthost && testRunPayload.TestSessionInfo == null ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun( this, testRunPayload.DebuggingEnabled) : null; testRequestManager.RunTests(testRunPayload, customLauncher, new DesignModeTestEventsRegistrar(this), this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartTestRun: " + ex); var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); var runCompletePayload = new TestRunCompletePayload() { TestRunCompleteArgs = new TestRunCompleteEventArgs(null, false, true, ex, null, TimeSpan.MinValue), LastRunTests = null }; // Send run complete to translation layer this.communicationManager.SendMessage(MessageType.ExecutionComplete, runCompletePayload); } }); }
public void DiscoverTestsShouldPassSameProtocolConfigInRequestData() { var payload = new DiscoveryRequestPayload() { Sources = new List <string>() { "a", "b" } }; var mockProtocolConfig = new ProtocolConfig { Version = 4 }; IRequestData actualRequestData = null; var mockDiscoveryRequest = new Mock <IDiscoveryRequest>(); this.mockTestPlatform.Setup(mt => mt.CreateDiscoveryRequest(It.IsAny <IRequestData>(), It.IsAny <DiscoveryCriteria>())).Callback( (IRequestData requestData, DiscoveryCriteria discoveryCriteria) => { actualRequestData = requestData; }).Returns(mockDiscoveryRequest.Object); var mockDiscoveryRegistrar = new Mock <ITestDiscoveryEventsRegistrar>(); string testCaseFilterValue = "TestFilter"; CommandLineOptions.Instance.TestCaseFilterValue = testCaseFilterValue; this.testRequestManager = new TestRequestManager(CommandLineOptions.Instance, this.mockTestPlatform.Object, TestLoggerManager.Instance, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object); // Act this.testRequestManager.DiscoverTests(payload, mockDiscoveryRegistrar.Object, mockProtocolConfig); // Verify. Assert.AreEqual(4, actualRequestData.ProtocolConfig.Version); }
private void StartTestSession(StartTestSessionPayload payload, ITestRequestManager requestManager) { Task.Run(() => { var eventsHandler = new TestSessionEventsHandler(this.communicationManager); try { var customLauncher = payload.HasCustomHostLauncher ? DesignModeTestHostLauncherFactory.GetCustomHostLauncherForTestRun(this, payload.IsDebuggingEnabled) : null; requestManager.ResetOptions(); requestManager.StartTestSession(payload, customLauncher, eventsHandler, this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartTestSession: " + ex); eventsHandler.HandleLogMessage(TestMessageLevel.Error, ex.ToString()); eventsHandler.HandleStartTestSessionComplete(null); } }); }
/// <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); }
/// <summary> /// For Unit testing only /// </summary> internal PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager, IProcessHelper processHelper) : this(options, testRequestManager, InitializeDesignMode, processHelper) { }
/// <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); }
private void StartTestRunAttachmentsProcessing(TestRunAttachmentsProcessingPayload attachmentsProcessingPayload, ITestRequestManager testRequestManager) { Task.Run( () => { try { testRequestManager.ProcessTestRunAttachments(attachmentsProcessingPayload, new TestRunAttachmentsProcessingEventsHandler(this.communicationManager), this.protocolConfig); } catch (Exception ex) { EqtTrace.Error("DesignModeClient: Exception in StartTestRunAttachmentsProcessing: " + ex); var testMessagePayload = new TestMessagePayload { MessageLevel = TestMessageLevel.Error, Message = ex.ToString() }; this.communicationManager.SendMessage(MessageType.TestMessage, testMessagePayload); var payload = new TestRunAttachmentsProcessingCompletePayload() { Attachments = null }; // Send run complete to translation layer this.communicationManager.SendMessage(MessageType.TestRunAttachmentsProcessingComplete, 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: { 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); }
/// <summary> /// Default constructor. /// </summary> /// <param name="options"> /// The options. /// </param> /// <param name="testRequestManager"> Test request manager</param> public PortArgumentExecutor(CommandLineOptions options, ITestRequestManager testRequestManager) : this(options, testRequestManager, InitializeDesignMode) { }