// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixBuildTools.TestSupport.XunitExtensions { using System; using System.ComponentModel; using System.Threading; using System.Threading.Tasks; using Xunit.Abstractions; using Xunit.Sdk; public class SkippableFactTestCase : XunitTestCase { [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] public SkippableFactTestCase() { } public SkippableFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { } public override async Task RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { var skipMessageBus = new SkippableFactMessageBus(messageBus); var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource); if (skipMessageBus.DynamicallySkippedTestCount > 0) { result.Failed -= skipMessageBus.DynamicallySkippedTestCount; result.Skipped += skipMessageBus.DynamicallySkippedTestCount; } return result; } } }