// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Reflection; using System.Threading; using System.Threading.Tasks; using Xunit.Abstractions; using Xunit.Sdk; namespace Microsoft.AspNetCore.Testing { internal class AspNetTestRunner : XunitTestRunner { public AspNetTestRunner( ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource) { } protected override async Task InvokeTestMethodAsync(ExceptionAggregator aggregator) { var timeTaken = 0.0M; timeTaken = await InvokeTestMethodCoreAsync(aggregator); if (aggregator.HasExceptions) { return timeTaken; } return timeTaken; } private Task InvokeTestMethodCoreAsync(ExceptionAggregator aggregator) { var invoker = new AspNetTestInvoker(Test, MessageBus, TestClass, ConstructorArguments, TestMethod, TestMethodArguments, BeforeAfterAttributes, aggregator, CancellationTokenSource); return invoker.RunAsync(); } } }