internal DefaultEngineInvoker(ITestRequestHandler requestHandler, IDataCollectionTestCaseEventSender dataCollectionTestCaseEventSender, IProcessHelper processHelper) { this.processHelper = processHelper; this.requestHandler = requestHandler; this.dataCollectionTestCaseEventSender = dataCollectionTestCaseEventSender; }
public TestRequestHandlerTests() { this.mockCommunicationClient = new Mock <ICommunicationEndPoint>(); this.mockChannel = new Mock <ICommunicationChannel>(); this.dataSerializer = JsonDataSerializer.Instance; this.testHostConnectionInfo = new TestHostConnectionInfo { Endpoint = IPAddress.Loopback + ":123", Role = ConnectionRole.Host }; this.jobQueue = new JobQueue <Action>( action => { action(); }, "TestHostOperationQueue", 500, 25000000, true, message => EqtTrace.Error(message)); // Setup mock discovery and execution managers this.mockTestHostManagerFactory = new Mock <ITestHostManagerFactory>(); this.mockDiscoveryManager = new Mock <IDiscoveryManager>(); this.mockExecutionManager = new Mock <IExecutionManager>(); this.mockTestHostManagerFactory.Setup(mf => mf.GetDiscoveryManager()).Returns(this.mockDiscoveryManager.Object); this.mockTestHostManagerFactory.Setup(mf => mf.GetExecutionManager()).Returns(this.mockExecutionManager.Object); this.requestHandler = new TestableTestRequestHandler( this.testHostConnectionInfo, this.mockCommunicationClient.Object, JsonDataSerializer.Instance, jobQueue); }
private Task StartProcessingAsync(ITestRequestHandler requestHandler, ITestHostManagerFactory managerFactory) { var task = new Task( () => { // Wait for the connection to the sender and start processing requests from sender // Note that we are waiting here infinitely to connect to vstest.console, but at the same time vstest.console doesn't wait infinitely. // It has a default timeout of 60secs(which is configurable), & then it kills testhost.exe // The reason to wait infinitely, was remote debugging scenarios of UWP app, // in such cases after the app gets launched, VS debugger takes control of it, & causes a lot of delay, which frequently causes timeout with vstest.console. // One fix would be just double this timeout, but there is no telling how much time it can actually take. // Hence we are waiting here indefinitely, to avoid such guessed timeouts, & letting user kill the debugging if they feel it is taking too much time. // In other cases if vstest.console's timeout exceeds it will definitely such down the app. if (requestHandler.WaitForRequestSenderConnection(ClientListenTimeOut)) { EqtTrace.Info("DefaultEngineInvoker.StartProcessingAsync: Connected to vstest.console, Starting process requests."); requestHandler.ProcessRequests(managerFactory); } else { EqtTrace.Info( "DefaultEngineInvoker.StartProcessingAsync: RequestHandler timed out while connecting to the Sender."); throw new TimeoutException(); } }, TaskCreationOptions.LongRunning); task.Start(); return(task); }
public void WaitForRequestSenderConnectionShouldReturnFalseIfConnectionSetupTimesout() { this.requestHandler = new TestableTestRequestHandler( this.testHostConnectionInfo, this.mockCommunicationEndpointFactory.Object, JsonDataSerializer.Instance, jobQueue); this.requestHandler.InitializeCommunication(); Assert.IsFalse(this.requestHandler.WaitForRequestSenderConnection(1)); }
public void TestInit() { this.connectionInfo = new TestHostConnectionInfo { Endpoint = IPAddress.Loopback + ":0", Role = ConnectionRole.Client, Transport = Transport.Sockets }; this.mockCommunicationManager = new Mock <ICommunicationManager>(); this.mockDataSerializer = new Mock <IDataSerializer>(); this.testRequestHandler = new TestRequestHandler(this.mockCommunicationManager.Object, this.connectionInfo, this.mockDataSerializer.Object); }
public void CloseShouldCallStopServerOnCommunicationManagerIfTestRunnerIsServer() { // These settings are that recieved by Test runtime(testhost) this.connectionInfo = new TestHostConnectionInfo { Endpoint = IPAddress.Loopback + ":0", Role = ConnectionRole.Host, Transport = Transport.Sockets }; this.testRequestHandler = new TestRequestHandler(this.mockCommunicationManager.Object, this.connectionInfo, this.mockDataSerializer.Object); this.testRequestHandler.Close(); this.mockCommunicationManager.Verify(mc => mc.StopServer(), Times.Once); }
private Task StartProcessingAsync(ITestRequestHandler requestHandler, ITestHostManagerFactory managerFactory) { return(Task.Run(() => { // Wait for the connection to the sender and start processing requests from sender if (requestHandler.WaitForRequestSenderConnection(ClientListenTimeOut)) { requestHandler.ProcessRequests(managerFactory); } else { EqtTrace.Info("DefaultEngineInvoker: RequestHandler timed out while connecting to the Sender."); throw new TimeoutException(); } })); }
public void InitializeCommunicationShouldHostServerAndAcceptClientIfTestHostIsServer() { this.mockCommunicationManager.Setup(mc => mc.HostServer(new IPEndPoint(IPAddress.Loopback, 0))).Returns(new IPEndPoint(IPAddress.Loopback, 123)); // These settings are that received by(testhost) this.connectionInfo = new TestHostConnectionInfo { Endpoint = IPAddress.Loopback + ":0", Role = ConnectionRole.Host, Transport = Transport.Sockets }; this.testRequestHandler = new TestRequestHandler(this.mockCommunicationManager.Object, this.connectionInfo, this.mockDataSerializer.Object); this.testRequestHandler.InitializeCommunication(); this.mockCommunicationManager.Verify(mc => mc.HostServer(new IPEndPoint(IPAddress.Loopback, 0)), Times.Once); this.mockCommunicationManager.Verify(mc => mc.AcceptClientAsync(), Times.Once); }
/// <summary> /// Initializes a new instance of the <see cref="TestDiscoveryEventHandler"/> class. /// </summary> /// <param name="client"> The client. </param> public TestDiscoveryEventHandler(ITestRequestHandler requestHandler) { this.requestHandler = requestHandler; }
/// <summary> /// Initializes a new instance of the <see cref="TestRunEventsHandler"/> class. /// </summary> /// <param name="requestHandler">test request handler</param> public TestRunEventsHandler(ITestRequestHandler requestHandler) { this.requestHandler = requestHandler; }
/// <summary> /// Initializes a new instance of the <see cref="TestInitializeEventsHandler"/> class. /// </summary> /// <param name="requestHandler">test request handler</param> public TestInitializeEventsHandler(ITestRequestHandler requestHandler) { this.requestHandler = requestHandler; }