Пример #1
0
 void DiscoverMessageHandler(xua.IMessageSinkMessage message)
 {
     try
     {
         if (message is xua.ITestCaseDiscoveryMessage testCaseDiscovery)
         {
             Wrap(testCaseDiscovery.TestCase, true);
         }
         else if (message is xua.IDiscoveryCompleteMessage discoveryComplete)
         {
             _tcs.SetResult(true);
         }
         else if (message is xua.IErrorMessage errorMessage)
         {
             Console.WriteLine($"Error ocurred {errorMessage.ToString()}");
         }
         else
         {
             Console.WriteLine($"Unhandled message of type {message.GetType()}");
         }
     }
     catch (Exception ex)
     {
         _tcs.SetException(ex);
     }
 }
Пример #2
0
 private void FilterTestCases(xua.IMessageSinkMessage message)
 {
     try
     {
         if (message is xua.ITestCaseDiscoveryMessage testDiscovered)
         {
             if (_filter?.Pass(Wrap(testDiscovered.TestCase)) != false)
             {
                 _testsToRun.Add(testDiscovered.TestCase);
             }
         }
         else if (message is xua.IDiscoveryCompleteMessage discoveryComplete)
         {
             _tcsFilter.SetResult(_testsToRun.Count);
         }
         else if (message is xua.IErrorMessage errorMessage)
         {
             Console.WriteLine($"Error ocurred {errorMessage.ToString()}");
         }
         else
         {
             Console.WriteLine($"Unhandled message of type {message.GetType()}");
         }
     }
     catch (Exception ex)
     {
         _tcsFilter?.SetException(ex);
         _tcsRun?.SetException(ex);
         _tcs?.SetException(ex);
     }
 }
Пример #3
0
 void RunMessageHandler(xua.IMessageSinkMessage message)
 {
     try
     {
         if (message is xua.ITestAssemblyFinished assemblyFinished)
         {
             _tcsRun.SetResult(new TestResultWrapper(assemblyFinished));
         }
         else if (message is xua.ITestClassStarting classStarting)
         {
             var suite = Wrap(classStarting.TestClass);
             SetStarted(suite);
             OnTestStarted(new UnitTestTestEventArgs(suite));
         }
         else if (message is xua.ITestClassFinished classFinished)
         {
             var suite  = Wrap(classFinished.TestClass);
             var result = new TestResultWrapper(classFinished, suite);
             SetStatus(suite, result.Status);
             OnTestFinished(new UnitTestResultEventArgs(result));
         }
         else if (message is xua.ITestStarting testStarting)
         {
             OnTestStarted(new UnitTestTestEventArgs(Wrap(testStarting.TestCase)));
         }
         else if (message is xua.ITestFailed testFailed)
         {
             OnTestFinished(new UnitTestResultEventArgs(new TestResultWrapper(testFailed, Wrap(testFailed.TestCase))));
         }
         else if (message is xua.ITestPassed testPassed)
         {
             OnTestFinished(new UnitTestResultEventArgs(new TestResultWrapper(testPassed, Wrap(testPassed.TestCase))));
         }
         else if (message is xua.ITestSkipped testSkipped)
         {
             OnTestFinished(new UnitTestResultEventArgs(new TestResultWrapper(testSkipped, Wrap(testSkipped.TestCase))));
         }
         else if (message is xua.IErrorMessage errorMessage)
         {
             Console.WriteLine($"Error ocurred {errorMessage.ToString()}");
         }
         else
         {
             Console.WriteLine($"Unhandled message of type {message.GetType()}");
         }
     }
     catch (Exception ex)
     {
         _tcsRun.SetException(ex);
     }
 }
Пример #4
0
 bool xu.IMessageSinkWithTypes.OnMessageWithTypes(xua.IMessageSinkMessage message, HashSet <string> messageTypes)
 {
     messageHandler?.Invoke(message);
     return(!_cancel);
 }