Exemplo n.º 1
0
 private SampleTestResult Run(string testName, bool patched, int customTimeLimit = WaitForExit)
 {
     try
     {
         var result     = RunForResult(testName, patched, customTimeLimit);
         var testResult = SampleTestResult.TryCreateFromString(result);
         if (testResult.HasValue)
         {
             return(testResult.Value);
         }
         else
         {
             return(new SampleTestResult()
             {
                 Status = SampleTestResultStatus.Exception,
                 Message = "Test return unexpected result: " + result
             });
         }
     }
     catch (ProcessRunsToLongException ex)
     {
         return(new SampleTestResult()
         {
             Status = SampleTestResultStatus.Exception,
             Message = ex.Message
         });
     }
 }
Exemplo n.º 2
0
        public static SampleTestResult?TryCreateFromString(string input)
        {
            var match = m_resultMatcher.Match(input);

            if (!match.Success)
            {
                return(null);
            }
            var result = new SampleTestResult();
            var status = match.Groups["status"].Value;

            switch (status)
            {
            case "OK":
                result.Status = SampleTestResultStatus.Ok;
                break;

            case "ERROR":
                result.Status = SampleTestResultStatus.Error;
                break;

            case "EXCEPTION":
                result.Status = SampleTestResultStatus.Exception;
                break;

            default:
                throw new ArgumentException($"Regular matcher return unexpected status group {status}");
            }
            result.Message = match.Groups["message"].Value;
            return(result);
        }
Exemplo n.º 3
0
 protected void HandleResult(SampleTestResult result)
 {
     if (!result.IsSuccess)
     {
         Trace.TraceError(result.Message);
     }
     Assert.AreEqual(SampleTestResultStatus.Ok, result.Status);
 }