public async Task StartAgent_WithExecutableFile_StartsProcess() { // Arrange var exeFile = new FileInfo(AGENT_EXE_NAME); var cancel = new CancellationTokenSource(); // Act using (var remoteProcess = new RemoteAgentProcess(exeFile)) { cancel.CancelAfter(TimeSpan.FromSeconds(6)); await remoteProcess.StartAgentProcess(cancel.Token); // Assert Assert.IsTrue(remoteProcess.AgentIsRunning); await remoteProcess.WaitForExit(); } }
public async Task CancelToken_ForRunningAgent_ClosesProcess() { // Arrange var cancel = new CancellationTokenSource(); cancel.CancelAfter(TimeSpan.FromSeconds(8)); // Act using (var remoteProcess = new RemoteAgentProcess(new FileInfo(AGENT_EXE_NAME))) { await remoteProcess.StartAgentProcess(cancel.Token); await remoteProcess.WaitForExit(); // Assert Assert.IsFalse(remoteProcess.AgentIsRunning); } }
public async Task StartAgent_WithExecutableFile_ThrowsNoException() { // Arrange Exception exception = null; var cancel = new CancellationTokenSource(); cancel.CancelAfter(TimeSpan.FromSeconds(EXE_START_TIME)); try { // Act using (var remoteProcess = new RemoteAgentProcess(new FileInfo(AGENT_EXE_NAME))) { await remoteProcess.StartAgentProcess(cancel.Token); await remoteProcess.WaitForExit(); } } catch (Exception ex) { exception = ex; } // Assert Assert.IsNull(exception); cancel.Dispose(); }
public async Task Connect_RemoteAgentRunning_ConnectsToAgent() { // Arrange const string AGENT_EXE_NAME = "./Agent/RemoteHost.exe"; const int CONNECT_TIMEOUT_SECONDS = 20; var agentExecFile = new FileInfo(AGENT_EXE_NAME); var cancel = new CancellationTokenSource(); using (var remoteProcess = new RemoteAgentProcess(agentExecFile)) { await remoteProcess.StartAgentProcess(cancel.Token); // Act var connectTimeout = TimeSpan.FromSeconds(CONNECT_TIMEOUT_SECONDS); var client = new RemoteUnityDriverClient(connectTimeout); var connected = await client.Connect(); // Assert cancel.Cancel(); await remoteProcess.WaitForExit(); Assert.IsTrue(connected, "Failed to connect."); } }