Beispiel #1
0
        bool IMessageSinkWithTypes.OnMessageWithTypes(IMessageSinkMessage message, HashSet <string> messageTypes)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                cancelled = true;
            }

            if (DispatchMessage <ITestCaseDiscoveryMessage>(message, messageTypes, testDiscovered =>
            {
                ++testCasesDiscovered;
                if (TestCaseFilter == null || TestCaseFilter(testDiscovered.TestCase))
                {
                    testCasesToRun.Add(testDiscovered.TestCase);
                }
            }))
            {
                return(!cancelled);
            }

            if (DispatchMessage <IDiscoveryCompleteMessage>(message, messageTypes, discoveryComplete =>
            {
                OnDiscoveryComplete?.Invoke(new TestDiscoveryInfo(testCasesToRun, assemblyFileName));
                tcs.TrySetResult("");
            }))
            {
                return(!cancelled);
            }

            if (DispatchMessage <ITestAssemblyFinished>(message, messageTypes, assemblyFinished =>
            {
                OnExecutionComplete?.Invoke(new ExecutionCompleteInfo(assemblyFinished.TestsRun, assemblyFinished.TestsFailed, assemblyFinished.TestsSkipped, assemblyFinished.ExecutionTime));
                tcs.TrySetResult("");
            }))
            {
                return(!cancelled);
            }

            if (OnDiagnosticMessage != null)
            {
                if (DispatchMessage <IDiagnosticMessage>(message, messageTypes, m => OnDiagnosticMessage(new DiagnosticMessageInfo(m.Message))))
                {
                    return(!cancelled);
                }
            }
            if (OnTestFailed != null)
            {
                if (DispatchMessage <ITestFailed>(message, messageTypes, m => OnTestFailed(new TestFailedInfo(m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.ExecutionTime, m.Output, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
            }
            if (OnTestFinished != null)
            {
                if (DispatchMessage <ITestFinished>(message, messageTypes, m => OnTestFinished(new TestFinishedInfo(m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.ExecutionTime, m.Output))))
                {
                    return(!cancelled);
                }
            }
            if (OnTestOutput != null)
            {
                if (DispatchMessage <ITestOutput>(message, messageTypes, m => OnTestOutput(new TestOutputInfo(m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.Output))))
                {
                    return(!cancelled);
                }
            }
            if (OnTestPassed != null)
            {
                if (DispatchMessage <ITestPassed>(message, messageTypes, m => OnTestPassed(new TestPassedInfo(m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.ExecutionTime, m.Output))))
                {
                    return(!cancelled);
                }
            }
            if (OnTestSkipped != null)
            {
                if (DispatchMessage <ITestSkipped>(message, messageTypes, m => OnTestSkipped(new TestSkippedInfo(m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName, m.Reason))))
                {
                    return(!cancelled);
                }
            }
            if (OnTestStarting != null)
            {
                if (DispatchMessage <ITestStarting>(message, messageTypes, m => OnTestStarting(new TestStartingInfo(m.TestClass.Class.Name, m.TestMethod.Method.Name, m.TestCase.Traits, m.Test.DisplayName, m.TestCollection.DisplayName))))
                {
                    return(!cancelled);
                }
            }

            if (OnErrorMessage != null)
            {
                if (DispatchMessage <IErrorMessage>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.CatastrophicError, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
                if (DispatchMessage <ITestAssemblyCleanupFailure>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.TestAssemblyCleanupFailure, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
                if (DispatchMessage <ITestCaseCleanupFailure>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.TestCaseCleanupFailure, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
                if (DispatchMessage <ITestClassCleanupFailure>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.TestClassCleanupFailure, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
                if (DispatchMessage <ITestCleanupFailure>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.TestCleanupFailure, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
                if (DispatchMessage <ITestCollectionCleanupFailure>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.TestCollectionCleanupFailure, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
                if (DispatchMessage <ITestMethodCleanupFailure>(message, messageTypes, m => OnErrorMessage(new ErrorMessageInfo(ErrorMessageType.TestMethodCleanupFailure, m.ExceptionTypes.FirstOrDefault(), m.Messages.FirstOrDefault(), m.StackTraces.FirstOrDefault()))))
                {
                    return(!cancelled);
                }
            }

            return(!cancelled);
        }
Beispiel #2
0
 internal static extern void BtIf_Create(out IntPtr ppBtIf,
                                         OnDeviceResponded deviceResponded, OnInquiryComplete handleInquiryCompleted,
                                         OnDiscoveryComplete handleDiscoveryComplete);