public static ResultDTO CreateTestStarted(TestResult test) { var dto = new ResultDTO(MessageType.TestStarted); dto.testName = test.FullName; dto.testTimeout = test.TestComponent.timeout; return dto; }
public static ResultDTO CreateTestFinished(TestResult test) { var dto = new ResultDTO(MessageType.TestFinished); dto.testName = test.FullName; dto.testResult = GetSerializableTestResult(test); return dto; }
private void Transfer(ResultDTO dto, ITransferInterface transfer) { transfer.Transfer(ref dto.messageType); transfer.Transfer(ref dto.levelCount); transfer.Transfer(ref dto.loadedLevel); transfer.Transfer(ref dto.loadedLevelName); if(dto.messageType == ResultDTO.MessageType.Ping || dto.messageType == ResultDTO.MessageType.RunStarted || dto.messageType == ResultDTO.MessageType.RunFinished || dto.messageType == ResultDTO.MessageType.RunInterrupted) return; transfer.Transfer(ref dto.testName); transfer.Transfer(ref dto.testTimeout); if(dto.messageType == ResultDTO.MessageType.TestStarted) return; if(transfer is Reader) dto.testResult = new SerializableTestResult(); SerializableTestResult str = (SerializableTestResult)dto.testResult; transfer.Transfer(ref str.resultState); transfer.Transfer(ref str.message); transfer.Transfer(ref str.executed); transfer.Transfer(ref str.name); transfer.Transfer(ref str.fullName); transfer.Transfer(ref str.id); transfer.Transfer(ref str.isSuccess); transfer.Transfer(ref str.duration); transfer.Transfer(ref str.stackTrace); }
private bool SendDTO(ResultDTO dto) { if (m_LostConnection) return false; #if UTT_SOCKETS_SUPPORTED try { using (var tcpClient = new TcpClient()) { var result = tcpClient.BeginConnect(m_Ip, m_Port, null, null); var success = result.AsyncWaitHandle.WaitOne(m_ConnectionTimeout); if (!success) { return false; } try { tcpClient.EndConnect(result); } catch (SocketException) { m_LostConnection = true; return false; } var bf = new DTOFormatter(); bf.Serialize(tcpClient.GetStream(), dto); tcpClient.GetStream().Close(); tcpClient.Close(); Debug.Log("Sent " + dto.messageType); } } catch (SocketException e) { Debug.LogException(e); m_LostConnection = true; return false; } #endif // if UTT_SOCKETS_SUPPORTED return true; }
private bool SendDTO(ResultDTO dto) { if (lostConnection) return false; #if !UNITY_METRO try { using (var tcpClient = new TcpClient()) { var result = tcpClient.BeginConnect (ip, port, null, null); var success = result.AsyncWaitHandle.WaitOne(ConnectionTimeout); if (!success) { return false; } try { tcpClient.EndConnect (result); } catch (SocketException) { lostConnection = true; return false; } var bf = new BinaryFormatter(); bf.Serialize(tcpClient.GetStream(), dto); tcpClient.GetStream().Close (); tcpClient.Close(); UnityEngine.Debug.Log ("Sent " + dto.messageType); } } catch (SocketException e) { UnityEngine.Debug.LogException (e); lostConnection = true; return false; } #endif return true; }
public void Transfer(ref ResultDTO.MessageType val) { _stream.WriteByte((byte)val); }
public void Serialize (System.IO.Stream stream, ResultDTO dto) { Transfer(dto, new Writer(stream)); }
private void WriteResultsToLog(ResultDTO dto, List<ITestResult> list) { string result = "Run finished for: " + dto.loadedLevelName; var failCount = list.Count(t => t.Executed && !t.IsSuccess); if (failCount == 0) result += "\nAll tests passed"; else result += "\n" + failCount + " tests failed"; if (failCount == 0) Debug.Log(result); else Debug.LogWarning(result); }
public void RunStarted(string platform, List <TestComponent> testsToRun) { SendDTO(ResultDTO.CreateRunStarted()); }
public void RunFinished(List <TestResult> testResults) { SendDTO(ResultDTO.CreateRunFinished(testResults)); }
public static ResultDTO CreateRunFinished(List<TestResult> testResults) { var dto = new ResultDTO(MessageType.RunFinished); return dto; }
public static ResultDTO CreateRunStarted() { var dto = new ResultDTO(MessageType.RunStarted); return dto; }
public void TestFinished(TestResult test) { SendDTO(ResultDTO.CreateTestFinished(test)); }
public void Transfer(ref ResultDTO.MessageType val) { val = (ResultDTO.MessageType)_stream.ReadByte(); }
public static ResultDTO CreateAllScenesFinished() { var dto = new ResultDTO(MessageType.AllScenesFinished); return dto; }
public void Serialize(Stream stream, ResultDTO dto) { Transfer(dto, new Writer(stream)); }
public void TestStarted(TestResult test) { SendDTO(ResultDTO.CreateTestStarted(test)); }
public static ResultDTO CreatePing() { var dto = new ResultDTO(MessageType.Ping); return dto; }
private void AcceptCallback(TcpClient client) { repaint = true; ResultDTO dto = null; try { lastMessageReceived = DateTime.Now; using (var stream = client.GetStream()) { var bf = new BinaryFormatter(); dto = (ResultDTO)bf.Deserialize(stream); stream.Close(); } client.Close(); } catch (ObjectDisposedException e) { Debug.LogException(e); statusLabel = "Got disconnected"; return; } catch (Exception e) { Debug.LogException(e); return; } switch (dto.messageType) { case ResultDTO.MessageType.TestStarted: statusLabel = dto.testName; testTimeout = TimeSpan.FromSeconds(dto.testTimeout); break; case ResultDTO.MessageType.TestFinished: testResults.Add(dto.testResult); testTimeout = TimeSpan.Zero; if (dto.testResult.Executed && !dto.testResult.IsSuccess) { testFailed = true; } break; case ResultDTO.MessageType.RunStarted: testResults = new List <ITestResult> (); statusLabel = "Run started: " + dto.loadedLevelName; break; case ResultDTO.MessageType.RunFinished: WriteResultsToLog(dto, testResults); if (!string.IsNullOrEmpty(configuration.resultsDir)) { var resultWriter = new XmlResultWriter(dto.loadedLevelName, testResults.ToArray()); try { var filePath = Path.Combine(configuration.resultsDir, dto.loadedLevelName + ".xml"); File.WriteAllText(filePath, resultWriter.GetTestResult()); } catch (Exception e) { Debug.LogException(e); } } if (dto.levelCount - dto.loadedLevel == 1) { running = false; runFinished = true; } break; case ResultDTO.MessageType.Ping: break; } }