예제 #1
0
        /// <inheritdoc/>
        public bool OnMessage(_MessageSinkMessage message)
        {
            Guard.ArgumentNotNull(nameof(message), message);

            if (message is _TestSkipped testSkipped)
            {
                var testFailed = new _TestFailed
                {
                    AssemblyUniqueID       = testSkipped.AssemblyUniqueID,
                    ExceptionParentIndices = new[] { -1 },
                    ExceptionTypes         = new[] { "FAIL_SKIP" },
                    ExecutionTime          = 0m,
                    Messages               = new[] { testSkipped.Reason },
                    Output                 = "",
                    StackTraces            = new[] { "" },
                    TestCaseUniqueID       = testSkipped.TestCaseUniqueID,
                    TestClassUniqueID      = testSkipped.TestClassUniqueID,
                    TestCollectionUniqueID = testSkipped.TestCollectionUniqueID,
                    TestMethodUniqueID     = testSkipped.TestMethodUniqueID,
                    TestUniqueID           = testSkipped.TestUniqueID
                };

                return(innerSink.OnMessage(testFailed));
            }

            // TODO: Shouldn't there be conversions of all the finished messages up the stack, to rectify the counts?

            if (message is _TestCollectionFinished testCollectionFinished)
            {
                testCollectionFinished = new _TestCollectionFinished
                {
                    AssemblyUniqueID       = testCollectionFinished.AssemblyUniqueID,
                    ExecutionTime          = testCollectionFinished.ExecutionTime,
                    TestCollectionUniqueID = testCollectionFinished.TestCollectionUniqueID,
                    TestsFailed            = testCollectionFinished.TestsFailed + testCollectionFinished.TestsSkipped,
                    TestsRun     = testCollectionFinished.TestsRun,
                    TestsSkipped = 0
                };

                return(innerSink.OnMessage(testCollectionFinished));
            }

            if (message is _TestAssemblyFinished assemblyFinished)
            {
                assemblyFinished = new _TestAssemblyFinished
                {
                    AssemblyUniqueID = assemblyFinished.AssemblyUniqueID,
                    ExecutionTime    = assemblyFinished.ExecutionTime,
                    TestsFailed      = assemblyFinished.TestsFailed + assemblyFinished.TestsSkipped,
                    TestsRun         = assemblyFinished.TestsRun,
                    TestsSkipped     = 0
                };

                return(innerSink.OnMessage(assemblyFinished));
            }

            return(innerSink.OnMessage(message));
        }
예제 #2
0
        /// <inheritdoc/>
        public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet <string> messageTypes)
        {
            var testSkipped = message.Cast <ITestSkipped>(messageTypes);

            if (testSkipped != null)
            {
                skipCount++;
                var testFailed = new TestFailed(testSkipped.Test, 0M, "",
                                                new[] { "FAIL_SKIP" },
                                                new[] { testSkipped.Reason },
                                                new[] { "" },
                                                new[] { -1 });
                return(innerSink.OnMessage(testFailed));
            }

            var testCollectionFinished = message.Cast <ITestCollectionFinished>(messageTypes);

            if (testCollectionFinished != null)
            {
                testCollectionFinished = new TestCollectionFinished(testCollectionFinished.TestCases,
                                                                    testCollectionFinished.TestCollection,
                                                                    testCollectionFinished.ExecutionTime,
                                                                    testCollectionFinished.TestsRun,
                                                                    testCollectionFinished.TestsFailed + testCollectionFinished.TestsSkipped,
                                                                    0);
                return(innerSink.OnMessage(testCollectionFinished));
            }

            var assemblyFinished = message.Cast <ITestAssemblyFinished>(messageTypes);

            if (assemblyFinished != null)
            {
                assemblyFinished = new TestAssemblyFinished(assemblyFinished.TestCases,
                                                            assemblyFinished.TestAssembly,
                                                            assemblyFinished.ExecutionTime,
                                                            assemblyFinished.TestsRun,
                                                            assemblyFinished.TestsFailed + assemblyFinished.TestsSkipped,
                                                            0);
                return(innerSink.OnMessage(assemblyFinished));
            }

            return(innerSink.OnMessageWithTypes(message, messageTypes));
        }
예제 #3
0
        /// <inheritdoc/>
        public bool OnMessage(_MessageSinkMessage message)
        {
            Guard.ArgumentNotNull(nameof(message), message);

            // Call the inner sink first, because we want to be able to depend on ExecutionSummary
            // being correctly filled out.
            var result = innerSink.OnMessage(message);

            return(message.DispatchWhen <_ErrorMessage>(HandleErrorMessage)

                   && message.DispatchWhen <_TestAssemblyCleanupFailure>(HandleTestAssemblyCleanupFailure) &&
                   message.DispatchWhen <_TestAssemblyFinished>(HandleTestAssemblyFinished) &&
                   message.DispatchWhen <_TestAssemblyStarting>(HandleTestAssemblyStarting)

                   && message.DispatchWhen <_TestCaseCleanupFailure>(HandleTestCaseCleanupFailure) &&
                   message.DispatchWhen <_TestCaseFinished>(HandleTestCaseFinished) &&
                   message.DispatchWhen <_TestCaseStarting>(HandleTestCaseStarting)

                   && message.DispatchWhen <_TestClassCleanupFailure>(HandleTestClassCleanupFailure) &&
                   message.DispatchWhen <_TestClassFinished>(HandleTestClassFinished) &&
                   message.DispatchWhen <_TestClassStarting>(HandleTestClassStarting)

                   && message.DispatchWhen <_TestCollectionCleanupFailure>(HandleTestCollectionCleanupFailure) &&
                   message.DispatchWhen <_TestCollectionFinished>(HandleTestCollectionFinished) &&
                   message.DispatchWhen <_TestCollectionStarting>(HandleTestCollectionStarting)

                   && message.DispatchWhen <_TestMethodCleanupFailure>(HandleTestMethodCleanupFailure) &&
                   message.DispatchWhen <_TestMethodFinished>(HandleTestMethodFinished) &&
                   message.DispatchWhen <_TestMethodStarting>(HandleTestMethodStarting)

                   && message.DispatchWhen <_TestCleanupFailure>(HandleTestCleanupFailure) &&
                   message.DispatchWhen <_TestFailed>(HandleTestFailed) &&
                   message.DispatchWhen <_TestFinished>(HandleTestFinished) &&
                   message.DispatchWhen <_TestPassed>(HandleTestPassed) &&
                   message.DispatchWhen <_TestSkipped>(HandleTestSkipped) &&
                   message.DispatchWhen <_TestStarting>(HandleTestStarting)

                   && result);
        }