From 2892bd077eb340ee9a687d94a30a759615283b91 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 30 Jul 2020 18:02:54 +0200 Subject: [PATCH] Remove AspNetCore Testing Infra that isn't used (#40091) --- .../src/CultureReplacer.cs | 79 ------ .../src/ExceptionAssertions.cs | 271 --------------------- .../Microsoft.AspNetCore.Testing/src/FlakyOn.cs | 44 ---- .../src/HelixQueues.cs | 21 -- .../src/HttpClientSlim.cs | 192 --------------- .../src/ITestMethodLifecycle.cs | 23 -- .../src/RepeatAttribute.cs | 27 -- .../src/RepeatContext.cs | 27 -- .../src/ReplaceCulture.cs | 70 ------ .../src/ShortClassNameAttribute.cs | 17 -- .../src/TaskExtensions.cs | 66 ----- .../src/TestContext.cs | 44 ---- .../src/TestFileOutputContext.cs | 146 ----------- .../src/TestOutputDirectoryAttribute.cs | 22 -- .../src/TestPathUtilities.cs | 37 --- .../src/TestPlatformHelper.cs | 23 -- .../src/Tracing/CollectingEventListener.cs | 63 ----- .../src/Tracing/EventAssert.cs | 63 ----- .../src/Tracing/EventSourceTestBase.cs | 42 ---- .../cs/netstandard2.0/EventSourceTestCollection.cs | 13 - .../src/xunit/AspNetTestAssemblyRunner.cs | 83 ------- .../src/xunit/AspNetTestCaseRunner.cs | 33 --- .../src/xunit/AspNetTestClassRunner.cs | 44 ---- .../src/xunit/AspNetTestCollectionRunner.cs | 75 ------ .../src/xunit/AspNetTestFramework.cs | 20 -- .../src/xunit/AspNetTestFrameworkExecutor.cs | 26 -- .../src/xunit/AspNetTestInvoker.cs | 84 ------- .../src/xunit/AspNetTestMethodRunner.cs | 73 ------ .../src/xunit/AspNetTestRunner.cs | 78 ------ .../src/xunit/AspNetTheoryTestCaseRunner.cs | 33 --- .../src/xunit/AssemblyFixtureAttribute.cs | 18 -- .../src/xunit/ConditionalFactAttribute.cs | 15 -- .../src/xunit/ConditionalFactDiscoverer.cs | 28 --- .../src/xunit/ConditionalTheoryAttribute.cs | 15 -- .../src/xunit/ConditionalTheoryDiscoverer.cs | 87 ------- .../src/xunit/DockerOnlyAttribute.cs | 38 --- .../EnvironmentVariableSkipConditionAttribute.cs | 95 -------- .../src/xunit/FlakyAttribute.cs | 95 -------- .../src/xunit/FlakyTraitDiscoverer.cs | 41 ---- .../src/xunit/FrameworkSkipConditionAttribute.cs | 57 ----- .../src/xunit/IEnvironmentVariable.cs | 10 - .../src/xunit/ITestCondition.cs | 12 - .../src/xunit/MaximumOSVersionAttribute.cs | 83 ------- .../src/xunit/MinimumOsVersionAttribute.cs | 79 ------ .../src/xunit/OSSkipConditionAttribute.cs | 62 ----- .../src/xunit/OperatingSystems.cs | 15 -- .../src/xunit/RuntimeFrameworks.cs | 16 -- .../src/xunit/SkipOnCIAttribute.cs | 43 ---- .../src/xunit/SkipOnHelixAttribute.cs | 50 ---- .../src/xunit/SkippedTestCase.cs | 51 ---- .../src/xunit/TestMethodExtensions.cs | 34 --- .../src/xunit/WORKAROUND_SkippedDataRowTestCase.cs | 83 ------- .../src/xunit/WindowsVersions.cs | 49 ---- .../test/AlphabeticalOrderer.cs | 22 -- .../test/AssemblyFixtureTest.cs | 47 ---- .../test/CollectingEventListenerTest.cs | 90 ------- .../test/ConditionalFactTest.cs | 66 ----- .../test/ConditionalTheoryTest.cs | 162 ------------ .../test/DockerTests.cs | 21 -- .../test/EnvironmentVariableSkipConditionTest.cs | 173 ------------- .../test/ExceptionAssertTest.cs | 39 --- .../test/FlakyAttributeTest.cs | 99 -------- .../test/HttpClientSlimTest.cs | 116 --------- .../test/MaximumOSVersionAttributeTest.cs | 89 ------- .../test/MaximumOSVersionTest.cs | 92 ------- .../test/MinimumOSVersionAttributeTest.cs | 77 ------ .../test/MinimumOSVersionTest.cs | 73 ------ .../test/OSSkipConditionAttributeTest.cs | 72 ------ .../test/OSSkipConditionTest.cs | 105 -------- .../test/Properties/AssemblyInfo.cs | 9 - .../test/RepeatTest.cs | 43 ---- .../test/ReplaceCultureAttributeTest.cs | 66 ----- .../test/SkipOnCITests.cs | 22 -- .../test/TaskExtensionsTest.cs | 18 -- .../test/TestAssemblyFixture.cs | 10 - .../test/TestCollectionFixture.cs | 10 - .../test/TestContextTest.cs | 83 ------- .../test/TestPathUtilitiesTest.cs | 35 --- .../test/TestPlatformHelperTest.cs | 55 ----- ...icrosoft.Extensions.Caching.Memory.Tests.csproj | 7 - .../tests/TimeExpirationTests.cs | 40 +-- ...osoft.Extensions.Configuration.Xml.Tests.csproj | 13 - .../tests/XmlConfigurationTest.cs | 22 +- ...ndencyInjection.ExternalContainers.Tests.csproj | 4 - ...oft.Extensions.DependencyInjection.Tests.csproj | 4 - .../ServiceCollectionServiceExtensionsTest.cs | 6 +- .../ServiceProviderServiceExtensionsTest.cs | 9 +- .../tests/DI.Tests/ServiceTableTest.cs | 16 +- ....Extensions.FileProviders.Physical.Tests.csproj | 6 +- .../tests/PhysicalFileProviderTests.cs | 1 - .../src/Deployers/SelfHostDeployer.cs | 1 - ...soft.Extensions.Hosting.Functional.Tests.csproj | 7 +- .../tests/FunctionalTests/ShutdownTests.cs | 1 - ...crosoft.Extensions.Logging.Testing.Tests.csproj | 2 - 94 files changed, 35 insertions(+), 4713 deletions(-) delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/CultureReplacer.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ExceptionAssertions.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/FlakyOn.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HelixQueues.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HttpClientSlim.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ITestMethodLifecycle.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatContext.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ReplaceCulture.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ShortClassNameAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TaskExtensions.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestContext.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestFileOutputContext.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestOutputDirectoryAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPathUtilities.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPlatformHelper.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/CollectingEventListener.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventAssert.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventSourceTestBase.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/contentFiles/cs/netstandard2.0/EventSourceTestCollection.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestAssemblyRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCaseRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestClassRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCollectionRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFramework.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFrameworkExecutor.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestInvoker.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestMethodRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTheoryTestCaseRunner.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AssemblyFixtureAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactDiscoverer.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryDiscoverer.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/DockerOnlyAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/EnvironmentVariableSkipConditionAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyTraitDiscoverer.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FrameworkSkipConditionAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/IEnvironmentVariable.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ITestCondition.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MaximumOSVersionAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MinimumOsVersionAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OSSkipConditionAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OperatingSystems.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/RuntimeFrameworks.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnCIAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnHelixAttribute.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkippedTestCase.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/TestMethodExtensions.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WORKAROUND_SkippedDataRowTestCase.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WindowsVersions.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AlphabeticalOrderer.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AssemblyFixtureTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/CollectingEventListenerTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalFactTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalTheoryTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/DockerTests.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/EnvironmentVariableSkipConditionTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ExceptionAssertTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/FlakyAttributeTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/HttpClientSlimTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionAttributeTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionAttributeTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionAttributeTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/Properties/AssemblyInfo.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/RepeatTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ReplaceCultureAttributeTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/SkipOnCITests.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TaskExtensionsTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestAssemblyFixture.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestCollectionFixture.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestContextTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPathUtilitiesTest.cs delete mode 100644 src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPlatformHelperTest.cs diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/CultureReplacer.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/CultureReplacer.cs deleted file mode 100644 index 85122f6..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/CultureReplacer.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Threading; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class CultureReplacer : IDisposable - { - private const string _defaultCultureName = "en-GB"; - private const string _defaultUICultureName = "en-US"; - private static readonly CultureInfo _defaultCulture = new CultureInfo(_defaultCultureName); - private readonly CultureInfo _originalCulture; - private readonly CultureInfo _originalUICulture; - private readonly long _threadId; - - // Culture => Formatting of dates/times/money/etc, defaults to en-GB because en-US is the same as InvariantCulture - // We want to be able to find issues where the InvariantCulture is used, but a specific culture should be. - // - // UICulture => Language - public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _defaultUICultureName) - : this(new CultureInfo(culture), new CultureInfo(uiCulture)) - { - } - - public CultureReplacer(CultureInfo culture, CultureInfo uiCulture) - { - _originalCulture = CultureInfo.CurrentCulture; - _originalUICulture = CultureInfo.CurrentUICulture; - _threadId = Thread.CurrentThread.ManagedThreadId; - CultureInfo.CurrentCulture = culture; - CultureInfo.CurrentUICulture = uiCulture; - } - - /// - /// The name of the culture that is used as the default value for CultureInfo.DefaultThreadCurrentCulture when CultureReplacer is used. - /// - public static string DefaultCultureName - { - get { return _defaultCultureName; } - } - - /// - /// The name of the culture that is used as the default value for [Thread.CurrentThread(NET45)/CultureInfo(K10)].CurrentUICulture when CultureReplacer is used. - /// - public static string DefaultUICultureName - { - get { return _defaultUICultureName; } - } - - /// - /// The culture that is used as the default value for [Thread.CurrentThread(NET45)/CultureInfo(K10)].CurrentCulture when CultureReplacer is used. - /// - public static CultureInfo DefaultCulture - { - get { return _defaultCulture; } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (disposing) - { - Assert.True(Thread.CurrentThread.ManagedThreadId == _threadId, - "The current thread is not the same as the thread invoking the constructor. This should never happen."); - CultureInfo.CurrentCulture = _originalCulture; - CultureInfo.CurrentUICulture = _originalUICulture; - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ExceptionAssertions.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ExceptionAssertions.cs deleted file mode 100644 index 10bc341..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ExceptionAssertions.cs +++ /dev/null @@ -1,271 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Reflection; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - // TODO: eventually want: public partial class Assert : Xunit.Assert - public static class ExceptionAssert - { - /// - /// Verifies that an exception of the given type (or optionally a derived type) is thrown. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception that was thrown, when successful - public static TException Throws(Action testCode) - where TException : Exception - { - return VerifyException(RecordException(testCode)); - } - - /// - /// Verifies that an exception of the given type is thrown. - /// Also verifies that the exception message matches. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception message to verify - /// The exception that was thrown, when successful - public static TException Throws(Action testCode, string exceptionMessage) - where TException : Exception - { - var ex = Throws(testCode); - VerifyExceptionMessage(ex, exceptionMessage); - return ex; - } - - /// - /// Verifies that an exception of the given type is thrown. - /// Also verifies that the exception message matches. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception message to verify - /// The exception that was thrown, when successful - public static async Task ThrowsAsync(Func testCode, string exceptionMessage) - where TException : Exception - { - // The 'testCode' Task might execute asynchronously in a different thread making it hard to enforce the thread culture. - // The correct way to verify exception messages in such a scenario would be to run the task synchronously inside of a - // culture enforced block. - var ex = await Assert.ThrowsAsync(testCode); - VerifyExceptionMessage(ex, exceptionMessage); - return ex; - } - - /// - /// Verifies that an exception of the given type is thrown. - /// Also verified that the exception message matches. - /// - /// The type of the exception expected to be thrown - /// A delegate to the code to be tested - /// The exception message to verify - /// The exception that was thrown, when successful - public static TException Throws(Func testCode, string exceptionMessage) - where TException : Exception - { - return Throws(() => { testCode(); }, exceptionMessage); - } - - /// - /// Verifies that the code throws an . - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception message to verify - /// The exception that was thrown, when successful - public static ArgumentException ThrowsArgument(Action testCode, string paramName, string exceptionMessage) - { - return ThrowsArgumentInternal(testCode, paramName, exceptionMessage); - } - - private static TException ThrowsArgumentInternal( - Action testCode, - string paramName, - string exceptionMessage) - where TException : ArgumentException - { - var ex = Throws(testCode); - if (paramName != null) - { - Assert.Equal(paramName, ex.ParamName); - } - VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); - return ex; - } - - /// - /// Verifies that the code throws an . - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception message to verify - /// The exception that was thrown, when successful - public static Task ThrowsArgumentAsync(Func testCode, string paramName, string exceptionMessage) - { - return ThrowsArgumentAsyncInternal(testCode, paramName, exceptionMessage); - } - - private static async Task ThrowsArgumentAsyncInternal( - Func testCode, - string paramName, - string exceptionMessage) - where TException : ArgumentException - { - var ex = await Assert.ThrowsAsync(testCode); - if (paramName != null) - { - Assert.Equal(paramName, ex.ParamName); - } - VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); - return ex; - } - - /// - /// Verifies that the code throws an . - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - public static ArgumentNullException ThrowsArgumentNull(Action testCode, string paramName) - { - var ex = Throws(testCode); - if (paramName != null) - { - Assert.Equal(paramName, ex.ParamName); - } - return ex; - } - - /// - /// Verifies that the code throws an ArgumentException with the expected message that indicates that the value cannot - /// be null or empty. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, string paramName) - { - return ThrowsArgumentInternal(testCode, paramName, "Value cannot be null or empty."); - } - - /// - /// Verifies that the code throws an ArgumentException with the expected message that indicates that the value cannot - /// be null or empty. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - public static Task ThrowsArgumentNullOrEmptyAsync(Func testCode, string paramName) - { - return ThrowsArgumentAsyncInternal(testCode, paramName, "Value cannot be null or empty."); - } - - /// - /// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot - /// be null or empty string. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - public static ArgumentException ThrowsArgumentNullOrEmptyString(Action testCode, string paramName) - { - return ThrowsArgumentInternal(testCode, paramName, "Value cannot be null or an empty string."); - } - - /// - /// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot - /// be null or empty string. - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception that was thrown, when successful - public static Task ThrowsArgumentNullOrEmptyStringAsync(Func testCode, string paramName) - { - return ThrowsArgumentAsyncInternal(testCode, paramName, "Value cannot be null or an empty string."); - } - - /// - /// Verifies that the code throws an ArgumentOutOfRangeException (or optionally any exception which derives from it). - /// - /// A delegate to the code to be tested - /// The name of the parameter that should throw the exception - /// The exception message to verify - /// The actual value provided - /// The exception that was thrown, when successful - public static ArgumentOutOfRangeException ThrowsArgumentOutOfRange(Action testCode, string paramName, string exceptionMessage, object actualValue = null) - { - var ex = ThrowsArgumentInternal(testCode, paramName, exceptionMessage); - - if (paramName != null) - { - Assert.Equal(paramName, ex.ParamName); - } - - if (actualValue != null) - { - Assert.Equal(actualValue, ex.ActualValue); - } - - return ex; - } - - // We've re-implemented all the xUnit.net Throws code so that we can get this - // updated implementation of RecordException which silently unwraps any instances - // of AggregateException. In addition to unwrapping exceptions, this method ensures - // that tests are executed in with a known set of Culture and UICulture. This prevents - // tests from failing when executed on a non-English machine. - private static Exception RecordException(Action testCode) - { - try - { - using (new CultureReplacer()) - { - testCode(); - } - return null; - } - catch (Exception exception) - { - return UnwrapException(exception); - } - } - - private static Exception UnwrapException(Exception exception) - { - var aggEx = exception as AggregateException; - return aggEx != null ? aggEx.GetBaseException() : exception; - } - - private static TException VerifyException(Exception exception) - { - var tie = exception as TargetInvocationException; - if (tie != null) - { - exception = tie.InnerException; - } - Assert.NotNull(exception); - return Assert.IsAssignableFrom(exception); - } - - private static void VerifyExceptionMessage(Exception exception, string expectedMessage, bool partialMatch = false) - { - if (expectedMessage != null) - { - if (!partialMatch) - { - Assert.Equal(expectedMessage, exception.Message); - } - else - { - Assert.Contains(expectedMessage, exception.Message); - } - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/FlakyOn.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/FlakyOn.cs deleted file mode 100644 index 45b72e3..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/FlakyOn.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Microsoft.AspNetCore.Testing -{ - public static class FlakyOn - { - public const string All = "All"; - - public static class Helix - { - public const string All = QueuePrefix + "All"; - - public const string Fedora28Amd64 = QueuePrefix + HelixQueues.Fedora28Amd64; - public const string Fedora27Amd64 = QueuePrefix + HelixQueues.Fedora27Amd64; - public const string Redhat7Amd64 = QueuePrefix + HelixQueues.Redhat7Amd64; - public const string Debian9Amd64 = QueuePrefix + HelixQueues.Debian9Amd64; - public const string Debian8Amd64 = QueuePrefix + HelixQueues.Debian8Amd64; - public const string Centos7Amd64 = QueuePrefix + HelixQueues.Centos7Amd64; - public const string Ubuntu1604Amd64 = QueuePrefix + HelixQueues.Ubuntu1604Amd64; - public const string Ubuntu1810Amd64 = QueuePrefix + HelixQueues.Ubuntu1810Amd64; - public const string macOS1012Amd64 = QueuePrefix + HelixQueues.macOS1012Amd64; - public const string Windows10Amd64 = QueuePrefix + HelixQueues.Windows10Amd64; - - private const string Prefix = "Helix:"; - private const string QueuePrefix = Prefix + "Queue:"; - } - - public static class AzP - { - public const string All = Prefix + "All"; - public const string Windows = OsPrefix + "Windows_NT"; - public const string macOS = OsPrefix + "Darwin"; - public const string Linux = OsPrefix + "Linux"; - - private const string Prefix = "AzP:"; - private const string OsPrefix = Prefix + "OS:"; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HelixQueues.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HelixQueues.cs deleted file mode 100644 index 19b9fde..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HelixQueues.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Testing -{ - public static class HelixQueues - { - public const string Fedora28Amd64 = "Fedora.28." + Amd64Suffix; - public const string Fedora27Amd64 = "Fedora.27." + Amd64Suffix; - public const string Redhat7Amd64 = "Redhat.7." + Amd64Suffix; - public const string Debian9Amd64 = "Debian.9." + Amd64Suffix; - public const string Debian8Amd64 = "Debian.8." + Amd64Suffix; - public const string Centos7Amd64 = "Centos.7." + Amd64Suffix; - public const string Ubuntu1604Amd64 = "Ubuntu.1604." + Amd64Suffix; - public const string Ubuntu1810Amd64 = "Ubuntu.1810." + Amd64Suffix; - public const string macOS1012Amd64 = "OSX.1012." + Amd64Suffix; - public const string Windows10Amd64 = "Windows.10.Amd64.ClientRS4.VS2017.Open"; // Doesn't have the default suffix! - - private const string Amd64Suffix = "Amd64.Open"; - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HttpClientSlim.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HttpClientSlim.cs deleted file mode 100644 index 3ef092e..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/HttpClientSlim.cs +++ /dev/null @@ -1,192 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.IO; -using System.Net; -using System.Net.Http; -using System.Net.Security; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Security.Authentication; -using System.Text; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Lightweight version of HttpClient implemented using Socket and SslStream. - /// - public static class HttpClientSlim - { - public static async Task GetStringAsync(string requestUri, bool validateCertificate = true) - => await GetStringAsync(new Uri(requestUri), validateCertificate).ConfigureAwait(false); - - public static async Task GetStringAsync(Uri requestUri, bool validateCertificate = true) - { - return await RetryRequest(async () => - { - using (var stream = await GetStream(requestUri, validateCertificate).ConfigureAwait(false)) - { - using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize: 1024, leaveOpen: true)) - { - await writer.WriteAsync($"GET {requestUri.PathAndQuery} HTTP/1.0\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Host: {GetHost(requestUri)}\r\n").ConfigureAwait(false); - await writer.WriteAsync("\r\n").ConfigureAwait(false); - } - - return await ReadResponse(stream).ConfigureAwait(false); - } - }); - } - - internal static string GetHost(Uri requestUri) - { - var authority = requestUri.Authority; - if (requestUri.HostNameType == UriHostNameType.IPv6) - { - // Make sure there's no % scope id. https://github.com/aspnet/KestrelHttpServer/issues/2637 - var address = IPAddress.Parse(requestUri.Host); - address = new IPAddress(address.GetAddressBytes()); // Drop scope Id. - if (requestUri.IsDefaultPort) - { - authority = $"[{address}]"; - } - else - { - authority = $"[{address}]:{requestUri.Port.ToString(CultureInfo.InvariantCulture)}"; - } - } - return authority; - } - - public static async Task PostAsync(string requestUri, HttpContent content, bool validateCertificate = true) - => await PostAsync(new Uri(requestUri), content, validateCertificate).ConfigureAwait(false); - - public static async Task PostAsync(Uri requestUri, HttpContent content, bool validateCertificate = true) - { - return await RetryRequest(async () => - { - using (var stream = await GetStream(requestUri, validateCertificate)) - { - using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize: 1024, leaveOpen: true)) - { - await writer.WriteAsync($"POST {requestUri.PathAndQuery} HTTP/1.0\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Host: {requestUri.Authority}\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Content-Type: {content.Headers.ContentType}\r\n").ConfigureAwait(false); - await writer.WriteAsync($"Content-Length: {content.Headers.ContentLength}\r\n").ConfigureAwait(false); - await writer.WriteAsync("\r\n").ConfigureAwait(false); - } - - await content.CopyToAsync(stream).ConfigureAwait(false); - - return await ReadResponse(stream).ConfigureAwait(false); - } - }); - } - - private static async Task ReadResponse(Stream stream) - { - using (var reader = new StreamReader(stream, Encoding.ASCII, detectEncodingFromByteOrderMarks: true, - bufferSize: 1024, leaveOpen: true)) - { - var response = await reader.ReadToEndAsync().ConfigureAwait(false); - - var status = GetStatus(response); - new HttpResponseMessage(status).EnsureSuccessStatusCode(); - - var body = response.Substring(response.IndexOf("\r\n\r\n") + 4); - return body; - } - } - - private static async Task RetryRequest(Func> retryBlock) - { - var retryCount = 1; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - retryCount = 3; - } - - for (var retry = 0; retry < retryCount; retry++) - { - try - { - return await retryBlock().ConfigureAwait(false); - } - catch (InvalidDataException) - { - if (retry == retryCount - 1) - { - throw; - } - } - } - - // This will never be hit. - throw new NotSupportedException(); - } - - private static HttpStatusCode GetStatus(string response) - { - var statusStart = response.IndexOf(' ') + 1; - var statusEnd = response.IndexOf(' ', statusStart) - 1; - var statusLength = statusEnd - statusStart + 1; - - if (statusLength < 1) - { - throw new InvalidDataException($"No StatusCode found in '{response}'"); - } - - return (HttpStatusCode)int.Parse(response.Substring(statusStart, statusLength)); - } - - private static async Task GetStream(Uri requestUri, bool validateCertificate) - { - var socket = await GetSocket(requestUri); - var stream = new NetworkStream(socket, ownsSocket: true); - - if (requestUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) - { - var sslStream = new SslStream(stream, leaveInnerStreamOpen: false, userCertificateValidationCallback: - validateCertificate ? null : (RemoteCertificateValidationCallback)((a, b, c, d) => true)); - - await sslStream.AuthenticateAsClientAsync(requestUri.Host, clientCertificates: null, - enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12, - checkCertificateRevocation: validateCertificate).ConfigureAwait(false); - return sslStream; - } - else - { - return stream; - } - } - - public static async Task GetSocket(Uri requestUri) - { - var tcs = new TaskCompletionSource(); - - var socketArgs = new SocketAsyncEventArgs(); - socketArgs.RemoteEndPoint = new DnsEndPoint(requestUri.DnsSafeHost, requestUri.Port); - socketArgs.Completed += (s, e) => tcs.TrySetResult(e.ConnectSocket); - - // Must use static ConnectAsync(), since instance Connect() does not support DNS names on OSX/Linux. - if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, socketArgs)) - { - await tcs.Task.ConfigureAwait(false); - } - - var socket = socketArgs.ConnectSocket; - - if (socket == null) - { - throw new SocketException((int)socketArgs.SocketError); - } - else - { - return socket; - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ITestMethodLifecycle.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ITestMethodLifecycle.cs deleted file mode 100644 index 7ea0bbf..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ITestMethodLifecycle.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Defines a lifecycle for attributes or classes that want to know about tests starting - /// or ending. Implement this on a test class, or attribute at the method/class/assembly level. - /// - /// - /// Requires defining as the test framework. - /// - public interface ITestMethodLifecycle - { - Task OnTestStartAsync(TestContext context, CancellationToken cancellationToken); - - Task OnTestEndAsync(TestContext context, Exception exception, CancellationToken cancellationToken); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatAttribute.cs deleted file mode 100644 index ca8c85c..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatAttribute.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Runs a test multiple times to stress flaky tests that are believed to be fixed. - /// This can be used on an assembly, class, or method name. Requires using the AspNetCore test framework. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)] - public class RepeatAttribute : Attribute - { - public RepeatAttribute(int runCount = 10) - { - RunCount = runCount; - } - - /// - /// The number of times to run a test. - /// - public int RunCount { get; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatContext.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatContext.cs deleted file mode 100644 index 91aa921..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/RepeatContext.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Threading; - -namespace Microsoft.AspNetCore.Testing -{ - public class RepeatContext - { - private static AsyncLocal _current = new AsyncLocal(); - - public static RepeatContext Current - { - get => _current.Value; - internal set => _current.Value = value; - } - - public RepeatContext(int limit) - { - Limit = limit; - } - - public int Limit { get; } - - public int CurrentIteration { get; set; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ReplaceCulture.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ReplaceCulture.cs deleted file mode 100644 index 2c2fb51..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ReplaceCulture.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Reflection; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Replaces the current culture and UI culture for the test. - /// - [AttributeUsage(AttributeTargets.Method)] - public class ReplaceCultureAttribute : BeforeAfterTestAttribute - { - private const string _defaultCultureName = "en-GB"; - private const string _defaultUICultureName = "en-US"; - private CultureInfo _originalCulture; - private CultureInfo _originalUICulture; - - /// - /// Replaces the current culture and UI culture to en-GB and en-US respectively. - /// - public ReplaceCultureAttribute() : - this(_defaultCultureName, _defaultUICultureName) - { - } - - /// - /// Replaces the current culture and UI culture based on specified values. - /// - public ReplaceCultureAttribute(string currentCulture, string currentUICulture) - { - Culture = new CultureInfo(currentCulture); - UICulture = new CultureInfo(currentUICulture); - } - - /// - /// The for the test. Defaults to en-GB. - /// - /// - /// en-GB is used here as the default because en-US is equivalent to the InvariantCulture. We - /// want to be able to find bugs where we're accidentally relying on the Invariant instead of the - /// user's culture. - /// - public CultureInfo Culture { get; } - - /// - /// The for the test. Defaults to en-US. - /// - public CultureInfo UICulture { get; } - - public override void Before(MethodInfo methodUnderTest) - { - _originalCulture = CultureInfo.CurrentCulture; - _originalUICulture = CultureInfo.CurrentUICulture; - - CultureInfo.CurrentCulture = Culture; - CultureInfo.CurrentUICulture = UICulture; - } - - public override void After(MethodInfo methodUnderTest) - { - CultureInfo.CurrentCulture = _originalCulture; - CultureInfo.CurrentUICulture = _originalUICulture; - } - } -} - diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ShortClassNameAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ShortClassNameAttribute.cs deleted file mode 100644 index ab4f0e1..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/ShortClassNameAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Used to specify that should used the - /// unqualified class name. This is needed when a fully-qualified class name exceeds - /// max path for logging. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false)] - public class ShortClassNameAttribute : Attribute - { - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TaskExtensions.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TaskExtensions.cs deleted file mode 100644 index 9cde37e..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TaskExtensions.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.AspNetCore.Testing -{ - public static class TaskExtensions - { - public static async Task TimeoutAfter(this Task task, TimeSpan timeout, - [CallerFilePath] string filePath = null, - [CallerLineNumber] int lineNumber = default) - { - // Don't create a timer if the task is already completed - // or the debugger is attached - if (task.IsCompleted || Debugger.IsAttached) - { - return await task; - } - - var cts = new CancellationTokenSource(); - if (task == await Task.WhenAny(task, Task.Delay(timeout, cts.Token))) - { - cts.Cancel(); - return await task; - } - else - { - throw new TimeoutException(CreateMessage(timeout, filePath, lineNumber)); - } - } - - public static async Task TimeoutAfter(this Task task, TimeSpan timeout, - [CallerFilePath] string filePath = null, - [CallerLineNumber] int lineNumber = default) - { - // Don't create a timer if the task is already completed - // or the debugger is attached - if (task.IsCompleted || Debugger.IsAttached) - { - await task; - return; - } - - var cts = new CancellationTokenSource(); - if (task == await Task.WhenAny(task, Task.Delay(timeout, cts.Token))) - { - cts.Cancel(); - await task; - } - else - { - throw new TimeoutException(CreateMessage(timeout, filePath, lineNumber)); - } - } - - private static string CreateMessage(TimeSpan timeout, string filePath, int lineNumber) - => string.IsNullOrEmpty(filePath) - ? $"The operation timed out after reaching the limit of {timeout.TotalMilliseconds}ms." - : $"The operation at {filePath}:{lineNumber} timed out after reaching the limit of {timeout.TotalMilliseconds}ms."; - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestContext.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestContext.cs deleted file mode 100644 index ead7052..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Reflection; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Provides access to contextual information about the running tests. Get access by - /// implementing . - /// - /// - /// Requires defining as the test framework. - /// - public sealed class TestContext - { - private Lazy _files; - - public TestContext( - Type testClass, - object[] constructorArguments, - MethodInfo testMethod, - object[] methodArguments, - ITestOutputHelper output) - { - TestClass = testClass; - ConstructorArguments = constructorArguments; - TestMethod = testMethod; - MethodArguments = methodArguments; - Output = output; - - _files = new Lazy(() => new TestFileOutputContext(this)); - } - - public Type TestClass { get; } - public MethodInfo TestMethod { get; } - public object[] ConstructorArguments { get; } - public object[] MethodArguments { get; } - public ITestOutputHelper Output { get; } - public TestFileOutputContext FileOutput => _files.Value; - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestFileOutputContext.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestFileOutputContext.cs deleted file mode 100644 index 91e9a1b..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestFileOutputContext.cs +++ /dev/null @@ -1,146 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Provides access to file storage for the running test. Get access by - /// implementing , and accessing . - /// - /// - /// Requires defining as the test framework. - /// - public sealed class TestFileOutputContext - { - private static char[] InvalidFileChars = new char[] - { - '\"', '<', '>', '|', '\0', - (char)1, (char)2, (char)3, (char)4, (char)5, (char)6, (char)7, (char)8, (char)9, (char)10, - (char)11, (char)12, (char)13, (char)14, (char)15, (char)16, (char)17, (char)18, (char)19, (char)20, - (char)21, (char)22, (char)23, (char)24, (char)25, (char)26, (char)27, (char)28, (char)29, (char)30, - (char)31, ':', '*', '?', '\\', '/', ' ', (char)127 - }; - - private readonly TestContext _parent; - - public TestFileOutputContext(TestContext parent) - { - _parent = parent; - - TestName = GetTestMethodName(parent.TestMethod, parent.MethodArguments); - TestClassName = GetTestClassName(parent.TestClass); - - AssemblyOutputDirectory = GetAssemblyBaseDirectory(_parent.TestClass.Assembly); - if (!string.IsNullOrEmpty(AssemblyOutputDirectory)) - { - TestClassOutputDirectory = Path.Combine(AssemblyOutputDirectory, TestClassName); - } - } - - public string TestName { get; } - - public string TestClassName { get; } - - public string AssemblyOutputDirectory { get; } - - public string TestClassOutputDirectory { get; } - - public string GetUniqueFileName(string prefix, string extension) - { - if (prefix == null) - { - throw new ArgumentNullException(nameof(prefix)); - } - - if (extension != null && !extension.StartsWith(".", StringComparison.Ordinal)) - { - throw new ArgumentException("The extension must start with '.' if one is provided.", nameof(extension)); - } - - var path = Path.Combine(TestClassOutputDirectory, $"{prefix}{extension}"); - - var i = 1; - while (File.Exists(path)) - { - path = Path.Combine(TestClassOutputDirectory, $"{prefix}{i++}{extension}"); - } - - return path; - } - - // Gets the output directory without appending the TFM or assembly name. - public static string GetOutputDirectory(Assembly assembly) - { - var attribute = assembly.GetCustomAttributes().OfType().FirstOrDefault(); - return attribute?.BaseDirectory; - } - - public static string GetAssemblyBaseDirectory(Assembly assembly, string baseDirectory = null) - { - var attribute = assembly.GetCustomAttributes().OfType().FirstOrDefault(); - baseDirectory = baseDirectory ?? attribute?.BaseDirectory; - if (string.IsNullOrEmpty(baseDirectory)) - { - return string.Empty; - } - - return Path.Combine(baseDirectory, assembly.GetName().Name, attribute.TargetFramework); - } - - public static bool GetPreserveExistingLogsInOutput(Assembly assembly) - { - var attribute = assembly.GetCustomAttributes().OfType().FirstOrDefault(); - return attribute.PreserveExistingLogsInOutput; - } - - public static string GetTestClassName(Type type) - { - var shortNameAttribute = - type.GetCustomAttribute() ?? - type.Assembly.GetCustomAttribute(); - var name = shortNameAttribute == null ? type.FullName : type.Name; - - // Try to shorten the class name using the assembly name - var assemblyName = type.Assembly.GetName().Name; - if (name.StartsWith(assemblyName + ".")) - { - name = name.Substring(assemblyName.Length + 1); - } - - return name; - } - - public static string GetTestMethodName(MethodInfo method, object[] arguments) - { - var name = arguments.Aggregate(method.Name, (a, b) => $"{a}-{(b ?? "null")}"); - return RemoveIllegalFileChars(name); - } - - public static string RemoveIllegalFileChars(string s) - { - var sb = new StringBuilder(); - - foreach (var c in s) - { - if (InvalidFileChars.Contains(c)) - { - if (sb.Length > 0 && sb[sb.Length - 1] != '_') - { - sb.Append('_'); - } - } - else - { - sb.Append(c); - } - } - return sb.ToString(); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestOutputDirectoryAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestOutputDirectoryAttribute.cs deleted file mode 100644 index 1a80126..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestOutputDirectoryAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = true)] - public class TestOutputDirectoryAttribute : Attribute - { - public TestOutputDirectoryAttribute(string preserveExistingLogsInOutput, string targetFramework, string baseDirectory = null) - { - TargetFramework = targetFramework; - BaseDirectory = baseDirectory; - PreserveExistingLogsInOutput = bool.Parse(preserveExistingLogsInOutput); - } - - public string BaseDirectory { get; } - public string TargetFramework { get; } - public bool PreserveExistingLogsInOutput { get; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPathUtilities.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPathUtilities.cs deleted file mode 100644 index b1711ce..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPathUtilities.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; - -namespace Microsoft.AspNetCore.Testing -{ - [Obsolete("This API is obsolete and the pattern its usage encouraged should not be used anymore. See https://github.com/dotnet/extensions/issues/1697 for details.")] - public class TestPathUtilities - { - public static string GetRepoRootDirectory() - { - return GetSolutionRootDirectory("Extensions"); - } - - public static string GetSolutionRootDirectory(string solution) - { - var applicationBasePath = AppContext.BaseDirectory; - var directoryInfo = new DirectoryInfo(applicationBasePath); - - do - { - var projectFileInfo = new FileInfo(Path.Combine(directoryInfo.FullName, $"{solution}.sln")); - if (projectFileInfo.Exists) - { - return projectFileInfo.DirectoryName; - } - - directoryInfo = directoryInfo.Parent; - } - while (directoryInfo.Parent != null); - - throw new Exception($"Solution file {solution}.sln could not be found in {applicationBasePath} or its parent directories."); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPlatformHelper.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPlatformHelper.cs deleted file mode 100644 index 4d85c00..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/TestPlatformHelper.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.AspNetCore.Testing -{ - public static class TestPlatformHelper - { - public static bool IsMono => - Type.GetType("Mono.Runtime") != null; - - public static bool IsWindows => - RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - - public static bool IsLinux => - RuntimeInformation.IsOSPlatform(OSPlatform.Linux); - - public static bool IsMac => - RuntimeInformation.IsOSPlatform(OSPlatform.OSX); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/CollectingEventListener.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/CollectingEventListener.cs deleted file mode 100644 index b9d392f..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/CollectingEventListener.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics.Tracing; -using System.Linq; - -namespace Microsoft.AspNetCore.Testing.Tracing -{ - public class CollectingEventListener : EventListener - { - private ConcurrentQueue _events = new ConcurrentQueue(); - - private object _lock = new object(); - - private Dictionary _existingSources = new Dictionary(StringComparer.OrdinalIgnoreCase); - private HashSet _requestedEventSources = new HashSet(); - - public void CollectFrom(string eventSourceName) - { - lock(_lock) - { - // Check if it's already been created - if(_existingSources.TryGetValue(eventSourceName, out var existingSource)) - { - // It has, so just enable it now - CollectFrom(existingSource); - } - else - { - // It hasn't, so queue this request for when it is created - _requestedEventSources.Add(eventSourceName); - } - } - } - - public void CollectFrom(EventSource eventSource) => EnableEvents(eventSource, EventLevel.Verbose, EventKeywords.All); - - public IReadOnlyList GetEventsWritten() => _events.ToArray(); - - protected override void OnEventSourceCreated(EventSource eventSource) - { - lock (_lock) - { - // Add this to the list of existing sources for future CollectEventsFrom requests. - _existingSources[eventSource.Name] = eventSource; - - // Check if we have a pending request to enable it - if (_requestedEventSources.Contains(eventSource.Name)) - { - CollectFrom(eventSource); - } - } - } - - protected override void OnEventWritten(EventWrittenEventArgs eventData) - { - _events.Enqueue(eventData); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventAssert.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventAssert.cs deleted file mode 100644 index d8601cf..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventAssert.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Diagnostics.Tracing; -using System.Linq; -using Xunit; - -namespace Microsoft.AspNetCore.Testing.Tracing -{ - public class EventAssert - { - private readonly int _expectedId; - private readonly string _expectedName; - private readonly EventLevel _expectedLevel; - private readonly IList<(string name, Action asserter)> _payloadAsserters = new List<(string, Action)>(); - - public EventAssert(int expectedId, string expectedName, EventLevel expectedLevel) - { - _expectedId = expectedId; - _expectedName = expectedName; - _expectedLevel = expectedLevel; - } - - public static void Collection(IEnumerable events, params EventAssert[] asserts) - { - Assert.Collection( - events, - asserts.Select(a => a.CreateAsserter()).ToArray()); - } - - public static EventAssert Event(int id, string name, EventLevel level) - { - return new EventAssert(id, name, level); - } - - public EventAssert Payload(string name, object expectedValue) => Payload(name, actualValue => Assert.Equal(expectedValue, actualValue)); - - public EventAssert Payload(string name, Action asserter) - { - _payloadAsserters.Add((name, asserter)); - return this; - } - - private Action CreateAsserter() => Execute; - - private void Execute(EventWrittenEventArgs evt) - { - Assert.Equal(_expectedId, evt.EventId); - Assert.Equal(_expectedName, evt.EventName); - Assert.Equal(_expectedLevel, evt.Level); - - Action CreateNameAsserter((string name, Action asserter) val) - { - return actualValue => Assert.Equal(val.name, actualValue); - } - - Assert.Collection(evt.PayloadNames, _payloadAsserters.Select(CreateNameAsserter).ToArray()); - Assert.Collection(evt.Payload, _payloadAsserters.Select(t => t.asserter).ToArray()); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventSourceTestBase.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventSourceTestBase.cs deleted file mode 100644 index 012f4d5..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/Tracing/EventSourceTestBase.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Diagnostics.Tracing; -using Xunit; - -namespace Microsoft.AspNetCore.Testing.Tracing -{ - // This collection attribute is what makes the "magic" happen. It forces xunit to run all tests that inherit from this - // base class sequentially, preventing conflicts (since EventSource/EventListener is a process-global concept). - [Collection(CollectionName)] - public abstract class EventSourceTestBase : IDisposable - { - public const string CollectionName = "Microsoft.AspNetCore.Testing.Tracing.EventSourceTestCollection"; - - private readonly CollectingEventListener _listener; - - public EventSourceTestBase() - { - _listener = new CollectingEventListener(); - } - - protected void CollectFrom(string eventSourceName) - { - _listener.CollectFrom(eventSourceName); - } - - protected void CollectFrom(EventSource eventSource) - { - _listener.CollectFrom(eventSource); - } - - protected IReadOnlyList GetEvents() => _listener.GetEventsWritten(); - - public void Dispose() - { - _listener.Dispose(); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/contentFiles/cs/netstandard2.0/EventSourceTestCollection.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/contentFiles/cs/netstandard2.0/EventSourceTestCollection.cs deleted file mode 100644 index 407efc8..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/contentFiles/cs/netstandard2.0/EventSourceTestCollection.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Testing.Tracing -{ - // This file comes from Microsoft.AspNetCore.Testing and has to be defined in the test assembly. - // It enables EventSourceTestBase's parallel isolation functionality. - - [Xunit.CollectionDefinition(EventSourceTestBase.CollectionName, DisableParallelization = true)] - public class EventSourceTestCollection - { - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestAssemblyRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestAssemblyRunner.cs deleted file mode 100644 index fa954c2..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestAssemblyRunner.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public class AspNetTestAssemblyRunner : XunitTestAssemblyRunner - { - private readonly Dictionary _assemblyFixtureMappings = new Dictionary(); - - public AspNetTestAssemblyRunner( - ITestAssembly testAssembly, - IEnumerable testCases, - IMessageSink diagnosticMessageSink, - IMessageSink executionMessageSink, - ITestFrameworkExecutionOptions executionOptions) - : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions) - { - } - - protected override async Task AfterTestAssemblyStartingAsync() - { - await base.AfterTestAssemblyStartingAsync(); - - // Find all the AssemblyFixtureAttributes on the test assembly - Aggregator.Run(() => - { - var fixturesAttributes = ((IReflectionAssemblyInfo)TestAssembly.Assembly) - .Assembly - .GetCustomAttributes(typeof(AssemblyFixtureAttribute), false) - .Cast() - .ToList(); - - // Instantiate all the fixtures - foreach (var fixtureAttribute in fixturesAttributes) - { - var ctorWithDiagnostics = fixtureAttribute.FixtureType.GetConstructor(new[] { typeof(IMessageSink) }); - if (ctorWithDiagnostics != null) - { - _assemblyFixtureMappings[fixtureAttribute.FixtureType] = Activator.CreateInstance(fixtureAttribute.FixtureType, DiagnosticMessageSink); - } - else - { - _assemblyFixtureMappings[fixtureAttribute.FixtureType] = Activator.CreateInstance(fixtureAttribute.FixtureType); - } - } - }); - } - - protected override Task BeforeTestAssemblyFinishedAsync() - { - // Dispose fixtures - foreach (var disposable in _assemblyFixtureMappings.Values.OfType()) - { - Aggregator.Run(disposable.Dispose); - } - - return base.BeforeTestAssemblyFinishedAsync(); - } - - protected override Task RunTestCollectionAsync( - IMessageBus messageBus, - ITestCollection testCollection, - IEnumerable testCases, - CancellationTokenSource cancellationTokenSource) - => new AspNetTestCollectionRunner( - _assemblyFixtureMappings, - testCollection, - testCases, - DiagnosticMessageSink, - messageBus, - TestCaseOrderer, - new ExceptionAggregator(Aggregator), - cancellationTokenSource).RunAsync(); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCaseRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCaseRunner.cs deleted file mode 100644 index 9fa8595..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCaseRunner.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - internal class AspNetTestCaseRunner : XunitTestCaseRunner - { - public AspNetTestCaseRunner( - IXunitTestCase testCase, - string displayName, - string skipReason, - object[] constructorArguments, - object[] testMethodArguments, - IMessageBus messageBus, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource) - { - } - - protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) - { - return new AspNetTestRunner(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestClassRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestClassRunner.cs deleted file mode 100644 index faddd9f..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestClassRunner.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - internal class AspNetTestClassRunner : XunitTestClassRunner - { - public AspNetTestClassRunner( - ITestClass testClass, - IReflectionTypeInfo @class, - IEnumerable testCases, - IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - ITestCaseOrderer testCaseOrderer, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource, - IDictionary collectionFixtureMappings) - : base(testClass, @class, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource, collectionFixtureMappings) - { - } - - protected override Task RunTestMethodAsync(ITestMethod testMethod, IReflectionMethodInfo method, IEnumerable testCases, object[] constructorArguments) - { - var runner = new AspNetTestMethodRunner( - testMethod, - Class, - method, - testCases, - DiagnosticMessageSink, - MessageBus, - new ExceptionAggregator(Aggregator), - CancellationTokenSource, - constructorArguments); - return runner.RunAsync(); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCollectionRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCollectionRunner.cs deleted file mode 100644 index 24c2cd1..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestCollectionRunner.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public class AspNetTestCollectionRunner : XunitTestCollectionRunner - { - private readonly IDictionary _assemblyFixtureMappings; - private readonly IMessageSink _diagnosticMessageSink; - - public AspNetTestCollectionRunner( - Dictionary assemblyFixtureMappings, - ITestCollection testCollection, - IEnumerable testCases, - IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - ITestCaseOrderer testCaseOrderer, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - : base(testCollection, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource) - { - _assemblyFixtureMappings = assemblyFixtureMappings; - _diagnosticMessageSink = diagnosticMessageSink; - } - - protected override async Task AfterTestCollectionStartingAsync() - { - await base.AfterTestCollectionStartingAsync(); - - // note: We pass the assembly fixtures into the runner as ICollectionFixture<> - this seems to work OK without any - // drawbacks. It's reasonable that we could add IAssemblyFixture<> and related plumbing if it ever became required. - // - // The reason for assembly fixture is when we want to start/stop something as the project scope - tests can only be - // in one test collection at a time. - foreach (var mapping in _assemblyFixtureMappings) - { - CollectionFixtureMappings.Add(mapping.Key, mapping.Value); - } - } - - protected override Task BeforeTestCollectionFinishedAsync() - { - // We need to remove the assembly fixtures so they won't get disposed. - foreach (var mapping in _assemblyFixtureMappings) - { - CollectionFixtureMappings.Remove(mapping.Key); - } - - return base.BeforeTestCollectionFinishedAsync(); - } - - protected override Task RunTestClassAsync(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable testCases) - { - var runner = new AspNetTestClassRunner( - testClass, - @class, - testCases, - DiagnosticMessageSink, - MessageBus, - TestCaseOrderer, - new ExceptionAggregator(Aggregator), - CancellationTokenSource, - CollectionFixtureMappings); - return runner.RunAsync(); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFramework.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFramework.cs deleted file mode 100644 index 369dece..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFramework.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Reflection; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public class AspNetTestFramework : XunitTestFramework - { - public AspNetTestFramework(IMessageSink messageSink) - : base(messageSink) - { - } - - protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName) - => new AspNetTestFrameworkExecutor(assemblyName, SourceInformationProvider, DiagnosticMessageSink); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFrameworkExecutor.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFrameworkExecutor.cs deleted file mode 100644 index ffbab11..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestFrameworkExecutor.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Reflection; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public class AspNetTestFrameworkExecutor : XunitTestFrameworkExecutor - { - public AspNetTestFrameworkExecutor(AssemblyName assemblyName, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink) - : base(assemblyName, sourceInformationProvider, diagnosticMessageSink) - { - } - - protected override async void RunTestCases(IEnumerable testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions) - { - using (var assemblyRunner = new AspNetTestAssemblyRunner(TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink, executionOptions)) - { - await assemblyRunner.RunAsync(); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestInvoker.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestInvoker.cs deleted file mode 100644 index 118c0bd..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestInvoker.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - internal class AspNetTestInvoker : XunitTestInvoker - { - public AspNetTestInvoker( - ITest test, - IMessageBus messageBus, - Type testClass, - object[] constructorArguments, - MethodInfo testMethod, - object[] testMethodArguments, - IReadOnlyList beforeAfterAttributes, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, beforeAfterAttributes, aggregator, cancellationTokenSource) - { - } - - protected override async Task InvokeTestMethodAsync(object testClassInstance) - { - var output = new TestOutputHelper(); - output.Initialize(MessageBus, Test); - - var context = new TestContext(TestClass, ConstructorArguments, TestMethod, TestMethodArguments, output); - var lifecycleHooks = GetLifecycleHooks(testClassInstance, TestClass, TestMethod); - - await Aggregator.RunAsync(async () => - { - foreach (var lifecycleHook in lifecycleHooks) - { - await lifecycleHook.OnTestStartAsync(context, CancellationTokenSource.Token); - } - }); - - var time = await base.InvokeTestMethodAsync(testClassInstance); - - await Aggregator.RunAsync(async () => - { - var exception = Aggregator.HasExceptions ? Aggregator.ToException() : null; - foreach (var lifecycleHook in lifecycleHooks) - { - await lifecycleHook.OnTestEndAsync(context, exception, CancellationTokenSource.Token); - } - }); - - return time; - } - - private static IEnumerable GetLifecycleHooks(object testClassInstance, Type testClass, MethodInfo testMethod) - { - foreach (var attribute in testMethod.GetCustomAttributes(inherit: true).OfType()) - { - yield return attribute; - } - - if (testClassInstance is ITestMethodLifecycle instance) - { - yield return instance; - } - - foreach (var attribute in testClass.GetCustomAttributes(inherit: true).OfType()) - { - yield return attribute; - } - - foreach (var attribute in testClass.Assembly.GetCustomAttributes(inherit: true).OfType()) - { - yield return attribute; - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestMethodRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestMethodRunner.cs deleted file mode 100644 index 35f5e09..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestMethodRunner.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Testing.xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - internal class AspNetTestMethodRunner : XunitTestMethodRunner - { - private readonly object[] _constructorArguments; - private readonly IMessageSink _diagnosticMessageSink; - - public AspNetTestMethodRunner( - ITestMethod testMethod, - IReflectionTypeInfo @class, - IReflectionMethodInfo method, - IEnumerable testCases, - IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource, - object[] constructorArguments) - : base(testMethod, @class, method, testCases, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource, constructorArguments) - { - _diagnosticMessageSink = diagnosticMessageSink; - _constructorArguments = constructorArguments; - } - - protected override Task RunTestCaseAsync(IXunitTestCase testCase) - { - if (testCase.GetType() == typeof(XunitTestCase)) - { - // If we get here this is a 'regular' test case, not something that represents a skipped test. - // - // We can take control of it's invocation thusly. - var runner = new AspNetTestCaseRunner( - testCase, - testCase.DisplayName, - testCase.SkipReason, - _constructorArguments, - testCase.TestMethodArguments, - MessageBus, - new ExceptionAggregator(Aggregator), - CancellationTokenSource); - return runner.RunAsync(); - } - - if (testCase.GetType() == typeof(XunitTheoryTestCase)) - { - // If we get here this is a 'regular' theory test case, not something that represents a skipped test. - // - // We can take control of it's invocation thusly. - var runner = new AspNetTheoryTestCaseRunner( - testCase, - testCase.DisplayName, - testCase.SkipReason, - _constructorArguments, - _diagnosticMessageSink, - MessageBus, - new ExceptionAggregator(Aggregator), - CancellationTokenSource); - return runner.RunAsync(); - } - - return base.RunTestCaseAsync(testCase); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestRunner.cs deleted file mode 100644 index f1f0794..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTestRunner.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -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 repeatAttribute = GetRepeatAttribute(TestMethod); - if (repeatAttribute == null) - { - return await InvokeTestMethodCoreAsync(aggregator); - } - - var repeatContext = new RepeatContext(repeatAttribute.RunCount); - RepeatContext.Current = repeatContext; - - var timeTaken = 0.0M; - for (repeatContext.CurrentIteration = 0; repeatContext.CurrentIteration < repeatContext.Limit; repeatContext.CurrentIteration++) - { - 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(); - } - - private RepeatAttribute GetRepeatAttribute(MethodInfo methodInfo) - { - var attributeCandidate = methodInfo.GetCustomAttribute(); - if (attributeCandidate != null) - { - return attributeCandidate; - } - - attributeCandidate = methodInfo.DeclaringType.GetCustomAttribute(); - if (attributeCandidate != null) - { - return attributeCandidate; - } - - return methodInfo.DeclaringType.Assembly.GetCustomAttribute(); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTheoryTestCaseRunner.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTheoryTestCaseRunner.cs deleted file mode 100644 index f9d5810..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AspNetTheoryTestCaseRunner.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing.xunit -{ - internal class AspNetTheoryTestCaseRunner : XunitTheoryTestCaseRunner - { - public AspNetTheoryTestCaseRunner( - IXunitTestCase testCase, - string displayName, - string skipReason, - object[] constructorArguments, - IMessageSink diagnosticMessageSink, - IMessageBus messageBus, - ExceptionAggregator aggregator, - CancellationTokenSource cancellationTokenSource) - : base(testCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource) - { - } - - protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) - { - return new AspNetTestRunner(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AssemblyFixtureAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AssemblyFixtureAttribute.cs deleted file mode 100644 index 428eb02..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/AssemblyFixtureAttribute.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public class AssemblyFixtureAttribute : Attribute - { - public AssemblyFixtureAttribute(Type fixtureType) - { - FixtureType = fixtureType; - } - - public Type FixtureType { get; private set; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactAttribute.cs deleted file mode 100644 index 8f128fd..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - [XunitTestCaseDiscoverer("Microsoft.AspNetCore.Testing." + nameof(ConditionalFactDiscoverer), "Microsoft.AspNetCore.Testing")] - public class ConditionalFactAttribute : FactAttribute - { - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactDiscoverer.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactDiscoverer.cs deleted file mode 100644 index 339ee1d..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalFactDiscoverer.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit.Abstractions; -using Xunit.Sdk; - -// Do not change this namespace without changing the usage in ConditionalFactAttribute -namespace Microsoft.AspNetCore.Testing -{ - internal class ConditionalFactDiscoverer : FactDiscoverer - { - private readonly IMessageSink _diagnosticMessageSink; - - public ConditionalFactDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - _diagnosticMessageSink = diagnosticMessageSink; - } - - protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) - { - var skipReason = testMethod.EvaluateSkipConditions(); - return skipReason != null - ? new SkippedTestCase(skipReason, _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) - : base.CreateTestCase(discoveryOptions, testMethod, factAttribute); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryAttribute.cs deleted file mode 100644 index 6030392..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryAttribute.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - [XunitTestCaseDiscoverer("Microsoft.AspNetCore.Testing." + nameof(ConditionalTheoryDiscoverer), "Microsoft.AspNetCore.Testing")] - public class ConditionalTheoryAttribute : TheoryAttribute - { - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryDiscoverer.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryDiscoverer.cs deleted file mode 100644 index 2fbff9b..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ConditionalTheoryDiscoverer.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using Xunit.Abstractions; -using Xunit.Sdk; - -// Do not change this namespace without changing the usage in ConditionalTheoryAttribute -namespace Microsoft.AspNetCore.Testing -{ - internal class ConditionalTheoryDiscoverer : TheoryDiscoverer - { - public ConditionalTheoryDiscoverer(IMessageSink diagnosticMessageSink) - : base(diagnosticMessageSink) - { - } - - private sealed class OptionsWithPreEnumerationEnabled : ITestFrameworkDiscoveryOptions - { - private const string PreEnumerateTheories = "xunit.discovery.PreEnumerateTheories"; - - private readonly ITestFrameworkDiscoveryOptions _original; - - public OptionsWithPreEnumerationEnabled(ITestFrameworkDiscoveryOptions original) - => _original = original; - - public TValue GetValue(string name) - => (name == PreEnumerateTheories) ? (TValue)(object)true : _original.GetValue(name); - - public void SetValue(string name, TValue value) - => _original.SetValue(name, value); - } - - public override IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) - => base.Discover(new OptionsWithPreEnumerationEnabled(discoveryOptions), testMethod, theoryAttribute); - - protected override IEnumerable CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) - { - var skipReason = testMethod.EvaluateSkipConditions(); - return skipReason != null - ? new[] { new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) } - : base.CreateTestCasesForTheory(discoveryOptions, testMethod, theoryAttribute); - } - - protected override IEnumerable CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) - { - var skipReason = testMethod.EvaluateSkipConditions(); - if (skipReason == null && dataRow?.Length > 0) - { - var obj = dataRow[0]; - if (obj != null) - { - var type = obj.GetType(); - var property = type.GetProperty("Skip"); - if (property != null && property.PropertyType.Equals(typeof(string))) - { - skipReason = property.GetValue(obj) as string; - } - } - } - - return skipReason != null ? - base.CreateTestCasesForSkippedDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow, skipReason) - : base.CreateTestCasesForDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow); - } - - protected override IEnumerable CreateTestCasesForSkippedDataRow( - ITestFrameworkDiscoveryOptions discoveryOptions, - ITestMethod testMethod, - IAttributeInfo theoryAttribute, - object[] dataRow, - string skipReason) - { - return new[] - { - new WORKAROUND_SkippedDataRowTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, skipReason, dataRow), - }; - } - - [Obsolete] - protected override IXunitTestCase CreateTestCaseForSkippedDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow, string skipReason) - { - return new WORKAROUND_SkippedDataRowTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, skipReason, dataRow); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/DockerOnlyAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/DockerOnlyAttribute.cs deleted file mode 100644 index 0536a9d..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/DockerOnlyAttribute.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Method, Inherited = true, AllowMultiple = false)] - public sealed class DockerOnlyAttribute : Attribute, ITestCondition - { - public string SkipReason { get; } = "This test can only run in a Docker container."; - - public bool IsMet - { - get - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // we currently don't have a good way to detect if running in a Windows container - return false; - } - - const string procFile = "/proc/1/cgroup"; - if (!File.Exists(procFile)) - { - return false; - } - - var lines = File.ReadAllLines(procFile); - // typically the last line in the file is "1:name=openrc:/docker" - return lines.Reverse().Any(l => l.EndsWith("name=openrc:/docker", StringComparison.Ordinal)); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/EnvironmentVariableSkipConditionAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/EnvironmentVariableSkipConditionAttribute.cs deleted file mode 100644 index b7dbed4..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/EnvironmentVariableSkipConditionAttribute.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Skips a test when the value of an environment variable matches any of the supplied values. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public class EnvironmentVariableSkipConditionAttribute : Attribute, ITestCondition - { - private readonly string _variableName; - private readonly string[] _values; - private string _currentValue; - private readonly IEnvironmentVariable _environmentVariable; - - /// - /// Creates a new instance of . - /// - /// Name of the environment variable. - /// Value(s) of the environment variable to match for the test to be skipped - public EnvironmentVariableSkipConditionAttribute(string variableName, params string[] values) - : this(new EnvironmentVariable(), variableName, values) - { - } - - // To enable unit testing - internal EnvironmentVariableSkipConditionAttribute( - IEnvironmentVariable environmentVariable, - string variableName, - params string[] values) - { - if (environmentVariable == null) - { - throw new ArgumentNullException(nameof(environmentVariable)); - } - if (variableName == null) - { - throw new ArgumentNullException(nameof(variableName)); - } - if (values == null) - { - throw new ArgumentNullException(nameof(values)); - } - - _variableName = variableName; - _values = values; - _environmentVariable = environmentVariable; - } - - /// - /// Runs the test only if the value of the variable matches any of the supplied values. Default is True. - /// - public bool RunOnMatch { get; set; } = true; - - public bool IsMet - { - get - { - _currentValue = _environmentVariable.Get(_variableName); - var hasMatched = _values.Any(value => string.Compare(value, _currentValue, ignoreCase: true) == 0); - - if (RunOnMatch) - { - return hasMatched; - } - else - { - return !hasMatched; - } - } - } - - public string SkipReason - { - get - { - var value = _currentValue == null ? "(null)" : _currentValue; - return $"Test skipped on environment variable with name '{_variableName}' and value '{value}' " + - $"for the '{nameof(RunOnMatch)}' value of '{RunOnMatch}'."; - } - } - - private struct EnvironmentVariable : IEnvironmentVariable - { - public string Get(string name) - { - return Environment.GetEnvironmentVariable(name); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyAttribute.cs deleted file mode 100644 index a08dac8..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyAttribute.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Marks a test as "Flaky" so that the build will sequester it and ignore failures. - /// - /// - /// - /// This attribute works by applying xUnit.net "Traits" based on the criteria specified in the attribute - /// properties. Once these traits are applied, build scripts can include/exclude tests based on them. - /// - /// - /// All flakiness-related traits start with Flaky: and are grouped first by the process running the tests: Azure Pipelines (AzP) or Helix. - /// Then there is a segment specifying the "selector" which indicates where the test is flaky. Finally a segment specifying the value of that selector. - /// The value of these traits is always either "true" or the trait is not present. We encode the entire selector in the name of the trait because xUnit.net only - /// provides "==" and "!=" operators for traits, there is no way to check if a trait "contains" or "does not contain" a value. VSTest does support "contains" checks - /// but does not appear to support "does not contain" checks. Using this pattern means we can use simple "==" and "!=" checks to either only run flaky tests, or exclude - /// flaky tests. - /// - /// - /// - /// - /// [Fact] - /// [Flaky("...", HelixQueues.Fedora28Amd64, AzurePipelines.macOS)] - /// public void FlakyTest() - /// { - /// // Flakiness - /// } - /// - /// - /// - /// The above example generates the following facets: - /// - /// - /// - /// - /// Flaky:Helix:Queue:Fedora.28.Amd64.Open = true - /// - /// - /// Flaky:AzP:OS:Darwin = true - /// - /// - /// - /// - /// Given the above attribute, the Azure Pipelines macOS run can easily filter this test out by passing -notrait "Flaky:AzP:OS:all=true" -notrait "Flaky:AzP:OS:Darwin=true" - /// to xunit.console.exe. Similarly, it can run only flaky tests using -trait "Flaky:AzP:OS:all=true" -trait "Flaky:AzP:OS:Darwin=true" - /// - /// - [TraitDiscoverer("Microsoft.AspNetCore.Testing." + nameof(FlakyTraitDiscoverer), "Microsoft.AspNetCore.Testing")] - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)] - public sealed class FlakyAttribute : Attribute, ITraitAttribute - { - /// - /// Gets a URL to a GitHub issue tracking this flaky test. - /// - public string GitHubIssueUrl { get; } - - public IReadOnlyList Filters { get; } - - /// - /// Initializes a new instance of the class with the specified and a list of . If no - /// filters are provided, the test is considered flaky in all environments. - /// - /// - /// At least one filter is required. - /// - /// The URL to a GitHub issue tracking this flaky test. - /// The first filter that indicates where the test is flaky. Use a value from . - /// A list of additional filters that define where this test is flaky. Use values in . - public FlakyAttribute(string gitHubIssueUrl, string firstFilter, params string[] additionalFilters) - { - if (string.IsNullOrEmpty(gitHubIssueUrl)) - { - throw new ArgumentNullException(nameof(gitHubIssueUrl)); - } - - if (string.IsNullOrEmpty(firstFilter)) - { - throw new ArgumentNullException(nameof(firstFilter)); - } - - GitHubIssueUrl = gitHubIssueUrl; - var filters = new List(); - filters.Add(firstFilter); - filters.AddRange(additionalFilters); - Filters = filters; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyTraitDiscoverer.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyTraitDiscoverer.cs deleted file mode 100644 index 1964f20..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FlakyTraitDiscoverer.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using Xunit.Abstractions; -using Xunit.Sdk; - -// Do not change this namespace without changing the usage in FlakyAttribute -namespace Microsoft.AspNetCore.Testing -{ - public class FlakyTraitDiscoverer : ITraitDiscoverer - { - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - if (traitAttribute is ReflectionAttributeInfo attribute && attribute.Attribute is FlakyAttribute flakyAttribute) - { - return GetTraitsCore(flakyAttribute); - } - else - { - throw new InvalidOperationException("The 'Flaky' attribute is only supported via reflection."); - } - } - - private IEnumerable> GetTraitsCore(FlakyAttribute attribute) - { - if (attribute.Filters.Count > 0) - { - foreach (var filter in attribute.Filters) - { - yield return new KeyValuePair($"Flaky:{filter}", "true"); - } - } - else - { - yield return new KeyValuePair($"Flaky:All", "true"); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FrameworkSkipConditionAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FrameworkSkipConditionAttribute.cs deleted file mode 100644 index 906f0c4..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/FrameworkSkipConditionAttribute.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public class FrameworkSkipConditionAttribute : Attribute, ITestCondition - { - private readonly RuntimeFrameworks _excludedFrameworks; - - public FrameworkSkipConditionAttribute(RuntimeFrameworks excludedFrameworks) - { - _excludedFrameworks = excludedFrameworks; - } - - public bool IsMet - { - get - { - return CanRunOnThisFramework(_excludedFrameworks); - } - } - - public string SkipReason { get; set; } = "Test cannot run on this runtime framework."; - - private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) - { - if (excludedFrameworks == RuntimeFrameworks.None) - { - return true; - } - -#if NETFRAMEWORK - if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && - TestPlatformHelper.IsMono) - { - return false; - } - - if (excludedFrameworks.HasFlag(RuntimeFrameworks.CLR)) - { - return false; - } -#elif NETSTANDARD2_0 || NETCOREAPP - if (excludedFrameworks.HasFlag(RuntimeFrameworks.CoreCLR)) - { - return false; - } -#else -#error Target frameworks need to be updated. -#endif - return true; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/IEnvironmentVariable.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/IEnvironmentVariable.cs deleted file mode 100644 index 1fbe032..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/IEnvironmentVariable.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Testing -{ - internal interface IEnvironmentVariable - { - string Get(string name); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ITestCondition.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ITestCondition.cs deleted file mode 100644 index d15a78a..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/ITestCondition.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Testing -{ - public interface ITestCondition - { - bool IsMet { get; } - - string SkipReason { get; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MaximumOSVersionAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MaximumOSVersionAttribute.cs deleted file mode 100644 index 29b8921..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MaximumOSVersionAttribute.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Skips a test if the OS is the given type (Windows) and the OS version is greater than specified. - /// E.g. Specifying Window 8 skips on Win 10, but not on Linux. Combine with OSSkipConditionAttribute as needed. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public class MaximumOSVersionAttribute : Attribute, ITestCondition - { - private readonly OperatingSystems _targetOS; - private readonly Version _maxVersion; - private readonly OperatingSystems _currentOS; - private readonly Version _currentVersion; - private readonly bool _skip; - - public MaximumOSVersionAttribute(OperatingSystems operatingSystem, string maxVersion) : - this(operatingSystem, Version.Parse(maxVersion), GetCurrentOS(), GetCurrentOSVersion()) - { - } - - // to enable unit testing - internal MaximumOSVersionAttribute(OperatingSystems targetOS, Version maxVersion, OperatingSystems currentOS, Version currentVersion) - { - if (targetOS != OperatingSystems.Windows) - { - throw new NotImplementedException("Max version support is only implemented for Windows."); - } - _targetOS = targetOS; - _maxVersion = maxVersion; - _currentOS = currentOS; - // We drop the 4th field because it is not significant and it messes up the comparisons. - _currentVersion = new Version(currentVersion.Major, currentVersion.Minor, - // Major and Minor are required by the parser, but if Build isn't specified then it returns -1 - // which the constructor rejects. - currentVersion.Build == -1 ? 0 : currentVersion.Build); - - // Do not skip other OS's, Use OSSkipConditionAttribute or a separate MaximumOsVersionAttribute for that. - _skip = _targetOS == _currentOS && _maxVersion < _currentVersion; - SkipReason = $"This test requires {_targetOS} {_maxVersion} or earlier."; - } - - // Since a test would be executed only if 'IsMet' is true, return false if we want to skip - public bool IsMet => !_skip; - - public string SkipReason { get; set; } - - private static OperatingSystems GetCurrentOS() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return OperatingSystems.Windows; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return OperatingSystems.Linux; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return OperatingSystems.MacOSX; - } - throw new PlatformNotSupportedException(); - } - - static private Version GetCurrentOSVersion() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return Environment.OSVersion.Version; - } - else - { - // Not implemented, but this will still be called before the OS check happens so don't throw. - return new Version(0, 0); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MinimumOsVersionAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MinimumOsVersionAttribute.cs deleted file mode 100644 index bf37323..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/MinimumOsVersionAttribute.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Skips a test if the OS is the given type (Windows) and the OS version is less than specified. - /// E.g. Specifying Window 10.0 skips on Win 8, but not on Linux. Combine with OSSkipConditionAttribute as needed. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public class MinimumOSVersionAttribute : Attribute, ITestCondition - { - private readonly OperatingSystems _targetOS; - private readonly Version _minVersion; - private readonly OperatingSystems _currentOS; - private readonly Version _currentVersion; - private readonly bool _skip; - - public MinimumOSVersionAttribute(OperatingSystems operatingSystem, string minVersion) : - this(operatingSystem, Version.Parse(minVersion), GetCurrentOS(), GetCurrentOSVersion()) - { - } - - // to enable unit testing - internal MinimumOSVersionAttribute(OperatingSystems targetOS, Version minVersion, OperatingSystems currentOS, Version currentVersion) - { - if (targetOS != OperatingSystems.Windows) - { - throw new NotImplementedException("Min version support is only implemented for Windows."); - } - _targetOS = targetOS; - _minVersion = minVersion; - _currentOS = currentOS; - _currentVersion = currentVersion; - - // Do not skip other OS's, Use OSSkipConditionAttribute or a separate MinimumOSVersionAttribute for that. - _skip = _targetOS == _currentOS && _minVersion > _currentVersion; - SkipReason = $"This test requires {_targetOS} {_minVersion} or later."; - } - - // Since a test would be executed only if 'IsMet' is true, return false if we want to skip - public bool IsMet => !_skip; - - public string SkipReason { get; set; } - - private static OperatingSystems GetCurrentOS() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return OperatingSystems.Windows; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return OperatingSystems.Linux; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return OperatingSystems.MacOSX; - } - throw new PlatformNotSupportedException(); - } - - static private Version GetCurrentOSVersion() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return Environment.OSVersion.Version; - } - else - { - // Not implemented, but this will still be called before the OS check happens so don't throw. - return new Version(0, 0); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OSSkipConditionAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OSSkipConditionAttribute.cs deleted file mode 100644 index 2a804e3..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OSSkipConditionAttribute.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; - -namespace Microsoft.AspNetCore.Testing -{ - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)] - public class OSSkipConditionAttribute : Attribute, ITestCondition - { - private readonly OperatingSystems _excludedOperatingSystem; - private readonly OperatingSystems _osPlatform; - - public OSSkipConditionAttribute(OperatingSystems operatingSystem) : - this(operatingSystem, GetCurrentOS()) - { - } - - [Obsolete("Use the Minimum/MaximumOSVersionAttribute for version checks.", error: true)] - public OSSkipConditionAttribute(OperatingSystems operatingSystem, params string[] versions) : - this(operatingSystem, GetCurrentOS()) - { - } - - // to enable unit testing - internal OSSkipConditionAttribute(OperatingSystems operatingSystem, OperatingSystems osPlatform) - { - _excludedOperatingSystem = operatingSystem; - _osPlatform = osPlatform; - } - - public bool IsMet - { - get - { - var skip = (_excludedOperatingSystem & _osPlatform) == _osPlatform; - // Since a test would be excuted only if 'IsMet' is true, return false if we want to skip - return !skip; - } - } - - public string SkipReason { get; set; } = "Test cannot run on this operating system."; - - static private OperatingSystems GetCurrentOS() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return OperatingSystems.Windows; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - return OperatingSystems.Linux; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - return OperatingSystems.MacOSX; - } - throw new PlatformNotSupportedException(); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OperatingSystems.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OperatingSystems.cs deleted file mode 100644 index 7f04934..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/OperatingSystems.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - [Flags] - public enum OperatingSystems - { - Linux = 1, - MacOSX = 2, - Windows = 4, - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/RuntimeFrameworks.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/RuntimeFrameworks.cs deleted file mode 100644 index 274ea13..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/RuntimeFrameworks.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - [Flags] - public enum RuntimeFrameworks - { - None = 0, - Mono = 1 << 0, - CLR = 1 << 1, - CoreCLR = 1 << 2 - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnCIAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnCIAttribute.cs deleted file mode 100644 index c89001e..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnCIAttribute.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Skip test if running on CI - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)] - public class SkipOnCIAttribute : Attribute, ITestCondition - { - public SkipOnCIAttribute(string issueUrl = "") - { - IssueUrl = issueUrl; - } - - public string IssueUrl { get; } - - public bool IsMet - { - get - { - return !OnCI(); - } - } - - public string SkipReason - { - get - { - return $"This test is skipped on CI"; - } - } - - public static bool OnCI() => OnHelix() || OnAzdo(); - public static bool OnHelix() => !string.IsNullOrEmpty(GetTargetHelixQueue()); - public static string GetTargetHelixQueue() => Environment.GetEnvironmentVariable("helix"); - public static bool OnAzdo() => !string.IsNullOrEmpty(GetIfOnAzdo()); - public static string GetIfOnAzdo() => Environment.GetEnvironmentVariable("AGENT_OS"); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnHelixAttribute.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnHelixAttribute.cs deleted file mode 100644 index f0aa92b..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkipOnHelixAttribute.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// Skip test if running on helix (or a particular helix queue). - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)] - public class SkipOnHelixAttribute : Attribute, ITestCondition - { - public SkipOnHelixAttribute(string issueUrl) - { - if (string.IsNullOrEmpty(issueUrl)) - { - throw new ArgumentException(); - } - IssueUrl = issueUrl; - } - - public string IssueUrl { get; } - - public bool IsMet - { - get - { - var skip = OnHelix() && (Queues == null || Queues.ToLowerInvariant().Split(';').Contains(GetTargetHelixQueue().ToLowerInvariant())); - return !skip; - } - } - - // Queues that should be skipped on, i.e. "Windows.10.Amd64.ClientRS4.VS2017.Open;OSX.1012.Amd64.Open" - public string Queues { get; set; } - - public string SkipReason - { - get - { - return $"This test is skipped on helix"; - } - } - - public static bool OnHelix() => !string.IsNullOrEmpty(GetTargetHelixQueue()); - - public static string GetTargetHelixQueue() => Environment.GetEnvironmentVariable("helix"); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkippedTestCase.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkippedTestCase.cs deleted file mode 100644 index 890bb35..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/SkippedTestCase.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading; -using System.Threading.Tasks; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public class SkippedTestCase : XunitTestCase - { - private string _skipReason; - - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] - public SkippedTestCase() : base() - { - } - - public SkippedTestCase( - string skipReason, - IMessageSink diagnosticMessageSink, - TestMethodDisplay defaultMethodDisplay, - TestMethodDisplayOptions defaultMethodDisplayOptions, - ITestMethod testMethod, - object[] testMethodArguments = null) - : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) - { - _skipReason = skipReason; - } - - protected override string GetSkipReason(IAttributeInfo factAttribute) - => _skipReason ?? base.GetSkipReason(factAttribute); - - public override void Deserialize(IXunitSerializationInfo data) - { - _skipReason = data.GetValue(nameof(_skipReason)); - - // We need to call base after reading our value, because Deserialize will call - // into GetSkipReason. - base.Deserialize(data); - } - - public override void Serialize(IXunitSerializationInfo data) - { - base.Serialize(data); - data.AddValue(nameof(_skipReason), _skipReason); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/TestMethodExtensions.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/TestMethodExtensions.cs deleted file mode 100644 index 36b2919..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/TestMethodExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public static class TestMethodExtensions - { - public static string EvaluateSkipConditions(this ITestMethod testMethod) - { - var testClass = testMethod.TestClass.Class; - var assembly = testMethod.TestClass.TestCollection.TestAssembly.Assembly; - var conditionAttributes = testMethod.Method - .GetCustomAttributes(typeof(ITestCondition)) - .Concat(testClass.GetCustomAttributes(typeof(ITestCondition))) - .Concat(assembly.GetCustomAttributes(typeof(ITestCondition))) - .OfType() - .Select(attributeInfo => attributeInfo.Attribute); - - foreach (ITestCondition condition in conditionAttributes) - { - if (!condition.IsMet) - { - return condition.SkipReason; - } - } - - return null; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WORKAROUND_SkippedDataRowTestCase.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WORKAROUND_SkippedDataRowTestCase.cs deleted file mode 100644 index 22dea01..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WORKAROUND_SkippedDataRowTestCase.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - // This is a workaround for https://github.com/xunit/xunit/issues/1782 - as such, this code is a copy-paste - // from xUnit with the exception of fixing the bug. - // - // This will only work with [ConditionalTheory]. - internal class WORKAROUND_SkippedDataRowTestCase : XunitTestCase - { - string skipReason; - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] - public WORKAROUND_SkippedDataRowTestCase() { } - - /// - /// Initializes a new instance of the class. - /// - /// The message sink used to send diagnostic messages - /// Default method display to use (when not customized). - /// The test method this test case belongs to. - /// The reason that this test case will be skipped - /// The arguments for the test method. - [Obsolete("Please call the constructor which takes TestMethodDisplayOptions")] - public WORKAROUND_SkippedDataRowTestCase(IMessageSink diagnosticMessageSink, - TestMethodDisplay defaultMethodDisplay, - ITestMethod testMethod, - string skipReason, - object[] testMethodArguments = null) - : this(diagnosticMessageSink, defaultMethodDisplay, TestMethodDisplayOptions.None, testMethod, skipReason, testMethodArguments) { } - - /// - /// Initializes a new instance of the class. - /// - /// The message sink used to send diagnostic messages - /// Default method display to use (when not customized). - /// Default method display options to use (when not customized). - /// The test method this test case belongs to. - /// The reason that this test case will be skipped - /// The arguments for the test method. - public WORKAROUND_SkippedDataRowTestCase(IMessageSink diagnosticMessageSink, - TestMethodDisplay defaultMethodDisplay, - TestMethodDisplayOptions defaultMethodDisplayOptions, - ITestMethod testMethod, - string skipReason, - object[] testMethodArguments = null) - : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) - { - this.skipReason = skipReason; - } - - /// - public override void Deserialize(IXunitSerializationInfo data) - { - // SkipReason has to be read before we call base.Deserialize, this is the workaround. - this.skipReason = data.GetValue("SkipReason"); - - base.Deserialize(data); - } - - /// - protected override string GetSkipReason(IAttributeInfo factAttribute) - { - return skipReason; - } - - /// - public override void Serialize(IXunitSerializationInfo data) - { - base.Serialize(data); - - data.AddValue("SkipReason", skipReason); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WindowsVersions.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WindowsVersions.cs deleted file mode 100644 index 0939046..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/src/xunit/WindowsVersions.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace Microsoft.AspNetCore.Testing -{ - /// - /// https://en.wikipedia.org/wiki/Windows_10_version_history - /// - public static class WindowsVersions - { - public const string Win7 = "6.1"; - - [Obsolete("Use Win7 instead.", error: true)] - public const string Win2008R2 = Win7; - - public const string Win8 = "6.2"; - - public const string Win81 = "6.3"; - - public const string Win10 = "10.0"; - - /// - /// 1803, RS4, 17134 - /// - public const string Win10_RS4 = "10.0.17134"; - - /// - /// 1809, RS5, 17763 - /// - public const string Win10_RS5 = "10.0.17763"; - - /// - /// 1903, 19H1, 18362 - /// - public const string Win10_19H1 = "10.0.18362"; - - /// - /// 1909, 19H2, 18363 - /// - public const string Win10_19H2 = "10.0.18363"; - - /// - /// 2004, 20H1, 19033 - /// - public const string Win10_20H1 = "10.0.19033"; - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AlphabeticalOrderer.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AlphabeticalOrderer.cs deleted file mode 100644 index 34eef71..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AlphabeticalOrderer.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace Microsoft.AspNetCore.Testing -{ - public class AlphabeticalOrderer : ITestCaseOrderer - { - public IEnumerable OrderTestCases(IEnumerable testCases) - where TTestCase : ITestCase - { - var result = testCases.ToList(); - result.Sort((x, y) => StringComparer.OrdinalIgnoreCase.Compare(x.TestMethod.Method.Name, y.TestMethod.Method.Name)); - return result; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AssemblyFixtureTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AssemblyFixtureTest.cs deleted file mode 100644 index 15673ce..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/AssemblyFixtureTest.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - // We include a collection and assembly fixture to verify that they both still work. - [Collection("MyCollection")] - [TestCaseOrderer("Microsoft.AspNetCore.Testing.AlphabeticalOrderer", "Microsoft.AspNetCore.Testing.Tests")] - public class AssemblyFixtureTest - { - public AssemblyFixtureTest(TestAssemblyFixture assemblyFixture, TestCollectionFixture collectionFixture) - { - AssemblyFixture = assemblyFixture; - CollectionFixture = collectionFixture; - } - - public TestAssemblyFixture AssemblyFixture { get; } - public TestCollectionFixture CollectionFixture { get; } - - [Fact] - public void A() - { - Assert.NotNull(AssemblyFixture); - Assert.Equal(0, AssemblyFixture.Count); - - Assert.NotNull(CollectionFixture); - Assert.Equal(0, CollectionFixture.Count); - - AssemblyFixture.Count++; - CollectionFixture.Count++; - } - - [Fact] - public void B() - { - Assert.Equal(1, AssemblyFixture.Count); - Assert.Equal(1, CollectionFixture.Count); - } - } - - [CollectionDefinition("MyCollection", DisableParallelization = true)] - public class MyCollection : ICollectionFixture - { - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/CollectingEventListenerTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/CollectingEventListenerTest.cs deleted file mode 100644 index 466a14e..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/CollectingEventListenerTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.Tracing; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Testing.Tracing; -using Xunit; - -namespace Microsoft.AspNetCore.Testing.Tests -{ - // We are verifying here that when event listener tests are spread among multiple classes, they still - // work, even when run in parallel. To do that we have a bunch of tests in different classes (since - // that affects parallelism) and do some Task.Yielding in them. - public class CollectingEventListenerTests - { - public abstract class CollectingTestBase : EventSourceTestBase - { - [Fact] - public async Task CollectingEventListenerTest() - { - CollectFrom("Microsoft-AspNetCore-Testing-Test"); - - await Task.Yield(); - TestEventSource.Log.Test(); - await Task.Yield(); - TestEventSource.Log.TestWithPayload(42, 4.2); - await Task.Yield(); - - var events = GetEvents(); - EventAssert.Collection(events, - EventAssert.Event(1, "Test", EventLevel.Informational), - EventAssert.Event(2, "TestWithPayload", EventLevel.Verbose) - .Payload("payload1", 42) - .Payload("payload2", 4.2)); - } - } - - // These tests are designed to interfere with the collecting ones by running in parallel and writing events - public abstract class NonCollectingTestBase - { - [Fact] - public async Task CollectingEventListenerTest() - { - await Task.Yield(); - TestEventSource.Log.Test(); - await Task.Yield(); - TestEventSource.Log.TestWithPayload(42, 4.2); - await Task.Yield(); - } - } - - public class CollectingTests - { - public class A : CollectingTestBase { } - public class B : CollectingTestBase { } - public class C : CollectingTestBase { } - public class D : CollectingTestBase { } - public class E : CollectingTestBase { } - public class F : CollectingTestBase { } - public class G : CollectingTestBase { } - } - - public class NonCollectingTests - { - public class A : NonCollectingTestBase { } - public class B : NonCollectingTestBase { } - public class C : NonCollectingTestBase { } - public class D : NonCollectingTestBase { } - public class E : NonCollectingTestBase { } - public class F : NonCollectingTestBase { } - public class G : NonCollectingTestBase { } - } - } - - [EventSource(Name = "Microsoft-AspNetCore-Testing-Test")] - public class TestEventSource : EventSource - { - public static readonly TestEventSource Log = new TestEventSource(); - - private TestEventSource() - { - } - - [Event(eventId: 1, Level = EventLevel.Informational, Message = "Test")] - public void Test() => WriteEvent(1); - - [Event(eventId: 2, Level = EventLevel.Verbose, Message = "Test")] - public void TestWithPayload(int payload1, double payload2) => WriteEvent(2, payload1, payload2); - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalFactTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalFactTest.cs deleted file mode 100644 index c66728c..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalFactTest.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - [TestCaseOrderer("Microsoft.AspNetCore.Testing.AlphabeticalOrderer", "Microsoft.AspNetCore.Testing.Tests")] - public class ConditionalFactTest : IClassFixture - { - public ConditionalFactTest(ConditionalFactAsserter collector) - { - Asserter = collector; - } - - private ConditionalFactAsserter Asserter { get; } - - [Fact] - public void TestAlwaysRun() - { - // This is required to ensure that the type at least gets initialized. - Assert.True(true); - } - - [ConditionalFact(Skip = "Test is always skipped.")] - public void ConditionalFactSkip() - { - Assert.True(false, "This test should always be skipped."); - } - -#if NETCOREAPP - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CLR)] - public void ThisTestMustRunOnCoreCLR() - { - Asserter.TestRan = true; - } -#elif NETFRAMEWORK - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR)] - public void ThisTestMustRunOnCLR() - { - Asserter.TestRan = true; - } -#else -#error Target frameworks need to be updated. -#endif - - // Test is named this way to be the lowest test in the alphabet, it relies on test ordering - [Fact] - public void ZzzzzzzEnsureThisIsTheLastTest() - { - Assert.True(Asserter.TestRan); - } - - public class ConditionalFactAsserter : IDisposable - { - public bool TestRan { get; set; } - - public void Dispose() - { - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalTheoryTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalTheoryTest.cs deleted file mode 100644 index b55264f..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ConditionalTheoryTest.cs +++ /dev/null @@ -1,162 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Testing -{ - [TestCaseOrderer("Microsoft.AspNetCore.Testing.AlphabeticalOrderer", "Microsoft.AspNetCore.Testing.Tests")] - public class ConditionalTheoryTest : IClassFixture - { - public ConditionalTheoryTest(ConditionalTheoryAsserter asserter) - { - Asserter = asserter; - } - - public ConditionalTheoryAsserter Asserter { get; } - - [ConditionalTheory(Skip = "Test is always skipped.")] - [InlineData(0)] - public void ConditionalTheorySkip(int arg) - { - Assert.True(false, "This test should always be skipped."); - } - - private static int _conditionalTheoryRuns = 0; - - [ConditionalTheory] - [InlineData(0)] - [InlineData(1)] - [InlineData(2, Skip = "Skip these data")] - public void ConditionalTheoryRunOncePerDataLine(int arg) - { - _conditionalTheoryRuns++; - Assert.True(_conditionalTheoryRuns <= 2, $"Theory should run 2 times, but ran {_conditionalTheoryRuns} times."); - } - - [ConditionalTheory, Trait("Color", "Blue")] - [InlineData(1)] - public void ConditionalTheoriesShouldPreserveTraits(int arg) - { - Assert.True(true); - } - - [ConditionalTheory(Skip = "Skip this")] - [MemberData(nameof(GetInts))] - public void ConditionalTheoriesWithSkippedMemberData(int arg) - { - Assert.True(false, "This should never run"); - } - - private static int _conditionalMemberDataRuns = 0; - - [ConditionalTheory] - [InlineData(4)] - [MemberData(nameof(GetInts))] - public void ConditionalTheoriesWithMemberData(int arg) - { - _conditionalMemberDataRuns++; - Assert.True(_conditionalTheoryRuns <= 3, $"Theory should run 2 times, but ran {_conditionalMemberDataRuns} times."); - } - - public static TheoryData GetInts - => new TheoryData { 0, 1 }; - - [ConditionalTheory] - [OSSkipCondition(OperatingSystems.Windows)] - [OSSkipCondition(OperatingSystems.MacOSX)] - [OSSkipCondition(OperatingSystems.Linux)] - [MemberData(nameof(GetActionTestData))] - public void ConditionalTheoryWithFuncs(Func func) - { - Assert.True(false, "This should never run"); - } - - [Fact] - public void TestAlwaysRun() - { - // This is required to ensure that this type at least gets initialized. - Assert.True(true); - } - -#if NETCOREAPP - [ConditionalTheory] - [FrameworkSkipCondition(RuntimeFrameworks.CLR)] - [MemberData(nameof(GetInts))] - public void ThisTestMustRunOnCoreCLR(int value) - { - Asserter.TestRan = true; - } -#elif NETFRAMEWORK - [ConditionalTheory] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR)] - [MemberData(nameof(GetInts))] - public void ThisTestMustRunOnCLR(int value) - { - Asserter.TestRan = true; - } -#else -#error Target frameworks need to be updated. -#endif - - // Test is named this way to be the lowest test in the alphabet, it relies on test ordering - [Fact] - public void ZzzzzzzEnsureThisIsTheLastTest() - { - Assert.True(Asserter.TestRan); - } - - public static TheoryData> GetActionTestData - => new TheoryData> - { - (i) => i * 1 - }; - - public class ConditionalTheoryAsserter : IDisposable - { - public bool TestRan { get; set; } - - public void Dispose() - { - } - } - - [ConditionalTheory] - [MemberData(nameof(SkippableData))] - public void WithSkipableData(Skippable skippable) - { - Assert.Null(skippable.Skip); - Assert.Equal(1, skippable.Data); - } - - public static TheoryData SkippableData => new TheoryData - { - new Skippable() { Data = 1 }, - new Skippable() { Data = 2, Skip = "This row should be skipped." } - }; - - public class Skippable : IXunitSerializable - { - public Skippable() { } - public int Data { get; set; } - public string Skip { get; set; } - - public void Serialize(IXunitSerializationInfo info) - { - info.AddValue(nameof(Data), Data, typeof(int)); - } - - public void Deserialize(IXunitSerializationInfo info) - { - Data = info.GetValue(nameof(Data)); - } - - public override string ToString() - { - return Data.ToString(); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/DockerTests.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/DockerTests.cs deleted file mode 100644 index eb61e7c..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/DockerTests.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; -using Microsoft.AspNetCore.Testing; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class DockerTests - { - [ConditionalFact] - [DockerOnly] - [Trait("Docker", "true")] - public void DoesNotRunOnWindows() - { - Assert.False(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/EnvironmentVariableSkipConditionTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/EnvironmentVariableSkipConditionTest.cs deleted file mode 100644 index e855527..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/EnvironmentVariableSkipConditionTest.cs +++ /dev/null @@ -1,173 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class EnvironmentVariableSkipConditionTest - { - private readonly string _skipReason = "Test skipped on environment variable with name '{0}' and value '{1}'" + - $" for the '{nameof(EnvironmentVariableSkipConditionAttribute.RunOnMatch)}' value of '{{2}}'."; - - [Theory] - [InlineData("false")] - [InlineData("")] - [InlineData(null)] - public void IsMet_DoesNotMatch(string environmentVariableValue) - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("Run", environmentVariableValue), - "Run", - "true"); - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.False(isMet); - } - - [Theory] - [InlineData("True")] - [InlineData("TRUE")] - [InlineData("true")] - public void IsMet_DoesCaseInsensitiveMatch_OnValue(string environmentVariableValue) - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("Run", environmentVariableValue), - "Run", - "true"); - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.True(isMet); - Assert.Equal( - string.Format(_skipReason, "Run", environmentVariableValue, attribute.RunOnMatch), - attribute.SkipReason); - } - - [Fact] - public void IsMet_DoesSuccessfulMatch_OnNull() - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("Run", null), - "Run", - "true", null); // skip the test when the variable 'Run' is explicitly set to 'true' or is null (default) - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.True(isMet); - Assert.Equal( - string.Format(_skipReason, "Run", "(null)", attribute.RunOnMatch), - attribute.SkipReason); - } - - [Theory] - [InlineData("false")] - [InlineData("")] - [InlineData(null)] - public void IsMet_MatchesOnMultipleSkipValues(string environmentVariableValue) - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("Run", environmentVariableValue), - "Run", - "false", "", null); - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.True(isMet); - } - - [Fact] - public void IsMet_DoesNotMatch_OnMultipleSkipValues() - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("Build", "100"), - "Build", - "125", "126"); - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.False(isMet); - } - - [Theory] - [InlineData("CentOS")] - [InlineData(null)] - [InlineData("")] - public void IsMet_Matches_WhenRunOnMatchIsFalse(string environmentVariableValue) - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("LinuxFlavor", environmentVariableValue), - "LinuxFlavor", - "Ubuntu14.04") - { - // Example: Run this test on all OSes except on "Ubuntu14.04" - RunOnMatch = false - }; - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.True(isMet); - } - - [Fact] - public void IsMet_DoesNotMatch_WhenRunOnMatchIsFalse() - { - // Arrange - var attribute = new EnvironmentVariableSkipConditionAttribute( - new TestEnvironmentVariable("LinuxFlavor", "Ubuntu14.04"), - "LinuxFlavor", - "Ubuntu14.04") - { - // Example: Run this test on all OSes except on "Ubuntu14.04" - RunOnMatch = false - }; - - // Act - var isMet = attribute.IsMet; - - // Assert - Assert.False(isMet); - } - - private struct TestEnvironmentVariable : IEnvironmentVariable - { - private readonly string _varName; - - public TestEnvironmentVariable(string varName, string value) - { - _varName = varName; - Value = value; - } - - public string Value { get; private set; } - - public string Get(string name) - { - if(string.Equals(name, _varName, System.StringComparison.OrdinalIgnoreCase)) - { - return Value; - } - return string.Empty; - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ExceptionAssertTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ExceptionAssertTest.cs deleted file mode 100644 index 52455b0..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ExceptionAssertTest.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class ExceptionAssertTest - { - [Fact] - [ReplaceCulture("fr-FR", "fr-FR")] - public void AssertArgumentNullOrEmptyString_WorksInNonEnglishCultures() - { - // Arrange - Action action = () => - { - throw new ArgumentException("Value cannot be null or an empty string.", "foo"); - }; - - // Act and Assert - ExceptionAssert.ThrowsArgumentNullOrEmptyString(action, "foo"); - } - - [Fact] - [ReplaceCulture("fr-FR", "fr-FR")] - public void AssertArgumentOutOfRangeException_WorksInNonEnglishCultures() - { - // Arrange - Action action = () => - { - throw new ArgumentOutOfRangeException("foo", 10, "exception message."); - }; - - // Act and Assert - ExceptionAssert.ThrowsArgumentOutOfRange(action, "foo", "exception message.", 10); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/FlakyAttributeTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/FlakyAttributeTest.cs deleted file mode 100644 index db342c1..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/FlakyAttributeTest.cs +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using Xunit; - -namespace Microsoft.AspNetCore.Testing.Tests -{ - public class FlakyAttributeTest - { - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.All)] - public void AlwaysFlakyInCI() - { - if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HELIX")) || !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AGENT_OS"))) - { - throw new Exception("Flaky!"); - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.Helix.All)] - public void FlakyInHelixOnly() - { - if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HELIX"))) - { - throw new Exception("Flaky on Helix!"); - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.Helix.macOS1012Amd64, FlakyOn.Helix.Fedora28Amd64)] - public void FlakyInSpecificHelixQueue() - { - // Today we don't run Extensions tests on Helix, but this test should light up when we do. - var queueName = Environment.GetEnvironmentVariable("HELIX"); - if (!string.IsNullOrEmpty(queueName)) - { - var failingQueues = new HashSet(StringComparer.OrdinalIgnoreCase) { HelixQueues.macOS1012Amd64, HelixQueues.Fedora28Amd64 }; - if (failingQueues.Contains(queueName)) - { - throw new Exception($"Flaky on Helix Queue '{queueName}' !"); - } - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.AzP.All)] - public void FlakyInAzPOnly() - { - if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AGENT_OS"))) - { - throw new Exception("Flaky on AzP!"); - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.AzP.Windows)] - public void FlakyInAzPWindowsOnly() - { - if (string.Equals(Environment.GetEnvironmentVariable("AGENT_OS"), "Windows_NT")) - { - throw new Exception("Flaky on AzP Windows!"); - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.AzP.macOS)] - public void FlakyInAzPmacOSOnly() - { - if (string.Equals(Environment.GetEnvironmentVariable("AGENT_OS"), "Darwin")) - { - throw new Exception("Flaky on AzP macOS!"); - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.AzP.Linux)] - public void FlakyInAzPLinuxOnly() - { - if (string.Equals(Environment.GetEnvironmentVariable("AGENT_OS"), "Linux")) - { - throw new Exception("Flaky on AzP Linux!"); - } - } - - [Fact(Skip = "These tests are nice when you need them but annoying when on all the time.")] - [Flaky("http://example.com", FlakyOn.AzP.Linux, FlakyOn.AzP.macOS)] - public void FlakyInAzPNonWindowsOnly() - { - var agentOs = Environment.GetEnvironmentVariable("AGENT_OS"); - if (string.Equals(agentOs, "Linux") || string.Equals(agentOs, "Darwin")) - { - throw new Exception("Flaky on AzP non-Windows!"); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/HttpClientSlimTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/HttpClientSlimTest.cs deleted file mode 100644 index 10ae3f7..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/HttpClientSlimTest.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class HttpClientSlimTest - { - private static readonly byte[] _defaultResponse = Encoding.ASCII.GetBytes("test"); - - [Fact] - public async Task GetStringAsyncHttp() - { - using (var host = StartHost(out var address)) - { - Assert.Equal("test", await HttpClientSlim.GetStringAsync(address)); - } - } - - [Fact] - public async Task GetStringAsyncThrowsForErrorResponse() - { - using (var host = StartHost(out var address, statusCode: 500)) - { - await Assert.ThrowsAnyAsync(() => HttpClientSlim.GetStringAsync(address)); - } - } - - [Fact] - public async Task PostAsyncHttp() - { - using (var host = StartHost(out var address, handler: context => context.Request.InputStream.CopyToAsync(context.Response.OutputStream))) - { - Assert.Equal("test post", await HttpClientSlim.PostAsync(address, new StringContent("test post"))); - } - } - - [Fact] - public async Task PostAsyncThrowsForErrorResponse() - { - using (var host = StartHost(out var address, statusCode: 500)) - { - await Assert.ThrowsAnyAsync( - () => HttpClientSlim.PostAsync(address, new StringContent(""))); - } - } - - [Fact] - public void Ipv6ScopeIdsFilteredOut() - { - var requestUri = new Uri("http://[fe80::5d2a:d070:6fd6:1bac%7]:5003/"); - Assert.Equal("[fe80::5d2a:d070:6fd6:1bac]:5003", HttpClientSlim.GetHost(requestUri)); - } - - [Fact] - public void GetHostExcludesDefaultPort() - { - var requestUri = new Uri("http://[fe80::5d2a:d070:6fd6:1bac%7]:80/"); - Assert.Equal("[fe80::5d2a:d070:6fd6:1bac]", HttpClientSlim.GetHost(requestUri)); - } - - private HttpListener StartHost(out string address, int statusCode = 200, Func handler = null) - { - var listener = new HttpListener(); - var random = new Random(); - address = null; - - for (var i = 0; i < 10; i++) - { - try - { - // HttpListener doesn't support requesting port 0 (dynamic). - // Requesting port 0 from Sockets and then passing that to HttpListener is racy. - // Just keep trying until we find a free one. - address = $"http://localhost:{random.Next(1024, ushort.MaxValue)}/"; - listener.Prefixes.Add(address); - listener.Start(); - break; - } - catch (HttpListenerException) - { - // Address in use - listener.Close(); - listener = new HttpListener(); - } - } - - Assert.True(listener.IsListening, "IsListening"); - - _ = listener.GetContextAsync().ContinueWith(async task => - { - var context = task.Result; - context.Response.StatusCode = statusCode; - - if (handler == null) - { - await context.Response.OutputStream.WriteAsync(_defaultResponse, 0, _defaultResponse.Length); - } - else - { - await handler(context); - } - - context.Response.Close(); - }); - - return listener; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionAttributeTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionAttributeTest.cs deleted file mode 100644 index 1cc772c..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionAttributeTest.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class MaximumOSVersionAttributeTest - { - [Fact] - public void Linux_ThrowsNotImplemeneted() - { - Assert.Throws(() => new MaximumOSVersionAttribute(OperatingSystems.Linux, "2.5")); - } - - [Fact] - public void Mac_ThrowsNotImplemeneted() - { - Assert.Throws(() => new MaximumOSVersionAttribute(OperatingSystems.MacOSX, "2.5")); - } - - [Fact] - public void WindowsOrLinux_ThrowsNotImplemeneted() - { - Assert.Throws(() => new MaximumOSVersionAttribute(OperatingSystems.Linux | OperatingSystems.Windows, "2.5")); - } - - [Fact] - public void DoesNotSkip_ShortVersions() - { - var osSkipAttribute = new MaximumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5"), - OperatingSystems.Windows, - new Version("2.0")); - - Assert.True(osSkipAttribute.IsMet); - } - - [Fact] - public void DoesNotSkip_EarlierVersions() - { - var osSkipAttribute = new MaximumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5.9"), - OperatingSystems.Windows, - new Version("2.0.10.12")); - - Assert.True(osSkipAttribute.IsMet); - } - - [Fact] - public void DoesNotSkip_SameVersion() - { - var osSkipAttribute = new MaximumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5.10"), - OperatingSystems.Windows, - new Version("2.5.10.12")); - - Assert.True(osSkipAttribute.IsMet); - } - - [Fact] - public void Skip_LaterVersion() - { - var osSkipAttribute = new MaximumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5.11"), - OperatingSystems.Windows, - new Version("3.0.10.12")); - - Assert.False(osSkipAttribute.IsMet); - } - - [Fact] - public void DoesNotSkip_WhenOnlyVersionsMatch() - { - var osSkipAttribute = new MaximumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5.10.12"), - OperatingSystems.Linux, - new Version("2.5.10.12")); - - Assert.True(osSkipAttribute.IsMet); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionTest.cs deleted file mode 100644 index 1b0586a..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MaximumOSVersionTest.cs +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; -using Microsoft.Win32; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public class MaximumOSVersionTest - { - [ConditionalFact] - [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win7)] - public void RunTest_Win7DoesRunOnWin7() - { - Assert.True( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should only be running on Win7 or Win2008R2."); - } - - [ConditionalTheory] - [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win7)] - [InlineData(1)] - public void RunTheory_Win7DoesRunOnWin7(int arg) - { - Assert.True( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should only be running on Win7 or Win2008R2."); - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CLR, SkipReason = "https://github.com/xunit/xunit/issues/2076")] - [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_RS4)] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public void RunTest_Win10_RS4() - { - Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - var versionKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); - Assert.NotNull(versionKey); - var currentVersion = (string)versionKey.GetValue("CurrentBuildNumber"); - Assert.NotNull(currentVersion); - Assert.True(17134 >= int.Parse(currentVersion), $"Unexpected build number {currentVersion} on {Environment.OSVersion.Version}."); - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CLR, SkipReason = "https://github.com/xunit/xunit/issues/2076")] - [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_19H2)] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public void RunTest_Win10_19H2() - { - Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - var versionKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); - Assert.NotNull(versionKey); - var currentVersion = (string)versionKey.GetValue("CurrentBuildNumber"); - Assert.NotNull(currentVersion); - Assert.True(18363 >= int.Parse(currentVersion), $"Unexpected build number {currentVersion} on {Environment.OSVersion.Version}."); - } - } - - [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win7)] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public class OSMaxVersionClassTest - { - [ConditionalFact] - public void TestSkipClass_Win7DoesRunOnWin7() - { - Assert.True( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should only be running on Win7 or Win2008R2."); - } - } - - // Let this one run cross plat just to check the constructor logic. - [MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win7)] - public class OSMaxVersionCrossPlatTest - { - [ConditionalFact] - public void TestSkipClass_Win7DoesRunOnWin7() - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - Assert.True(Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should only be running on Win7 or Win2008R2."); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionAttributeTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionAttributeTest.cs deleted file mode 100644 index c4e1120..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionAttributeTest.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class MinimumOSVersionAttributeTest - { - [Fact] - public void Linux_ThrowsNotImplemeneted() - { - Assert.Throws(() => new MinimumOSVersionAttribute(OperatingSystems.Linux, "2.5")); - } - - [Fact] - public void Mac_ThrowsNotImplemeneted() - { - Assert.Throws(() => new MinimumOSVersionAttribute(OperatingSystems.MacOSX, "2.5")); - } - - [Fact] - public void WindowsOrLinux_ThrowsNotImplemeneted() - { - Assert.Throws(() => new MinimumOSVersionAttribute(OperatingSystems.Linux | OperatingSystems.Windows, "2.5")); - } - - [Fact] - public void DoesNotSkip_LaterVersions() - { - var osSkipAttribute = new MinimumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.0"), - OperatingSystems.Windows, - new Version("2.5")); - - Assert.True(osSkipAttribute.IsMet); - } - - [Fact] - public void DoesNotSkip_SameVersion() - { - var osSkipAttribute = new MinimumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5"), - OperatingSystems.Windows, - new Version("2.5")); - - Assert.True(osSkipAttribute.IsMet); - } - - [Fact] - public void Skip_EarlierVersion() - { - var osSkipAttribute = new MinimumOSVersionAttribute( - OperatingSystems.Windows, - new Version("3.0"), - OperatingSystems.Windows, - new Version("2.5")); - - Assert.False(osSkipAttribute.IsMet); - } - - [Fact] - public void DoesNotSkip_WhenOnlyVersionsMatch() - { - var osSkipAttribute = new MinimumOSVersionAttribute( - OperatingSystems.Windows, - new Version("2.5"), - OperatingSystems.Linux, - new Version("2.5")); - - Assert.True(osSkipAttribute.IsMet); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionTest.cs deleted file mode 100644 index ba45f1c..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/MinimumOSVersionTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; -using Microsoft.Win32; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class MinimumOSVersionTest - { - [ConditionalFact] - [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win8)] - public void RunTest_Win8DoesNotRunOnWin7() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should not be running on Win7 or Win2008R2."); - } - - [ConditionalTheory] - [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win8)] - [InlineData(1)] - public void RunTheory_Win8DoesNotRunOnWin7(int arg) - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should not be running on Win7 or Win2008R2."); - } - - [ConditionalFact] - [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_RS4)] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public void RunTest_Win10_RS4() - { - Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - var versionKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); - Assert.NotNull(versionKey); - var currentVersion = (string)versionKey.GetValue("CurrentBuildNumber"); - Assert.NotNull(currentVersion); - Assert.True(17134 <= int.Parse(currentVersion)); - } - - [ConditionalFact] - [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_19H2)] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public void RunTest_Win10_19H2() - { - Assert.True(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); - var versionKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); - Assert.NotNull(versionKey); - var currentVersion = (string)versionKey.GetValue("CurrentBuildNumber"); - Assert.NotNull(currentVersion); - Assert.True(18363 <= int.Parse(currentVersion)); - } - } - - [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win8)] - public class OSMinVersionClassTest - { - [ConditionalFact] - public void TestSkipClass_Win8DoesNotRunOnWin7() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && - Environment.OSVersion.Version.ToString().StartsWith("6.1"), - "Test should not be running on Win7 or Win2008R2."); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionAttributeTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionAttributeTest.cs deleted file mode 100644 index 53e2ed7..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionAttributeTest.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class OSSkipConditionAttributeTest - { - [Fact] - public void Skips_WhenOperatingSystemMatches() - { - // Act - var osSkipAttribute = new OSSkipConditionAttribute( - OperatingSystems.Windows, - OperatingSystems.Windows); - - // Assert - Assert.False(osSkipAttribute.IsMet); - } - - [Fact] - public void DoesNotSkip_WhenOperatingSystemDoesNotMatch() - { - // Act - var osSkipAttribute = new OSSkipConditionAttribute( - OperatingSystems.Linux, - OperatingSystems.Windows); - - // Assert - Assert.True(osSkipAttribute.IsMet); - } - - [Fact] - public void Skips_BothMacOSXAndLinux() - { - // Act - var osSkipAttributeLinux = new OSSkipConditionAttribute(OperatingSystems.Linux | OperatingSystems.MacOSX, OperatingSystems.Linux); - var osSkipAttributeMacOSX = new OSSkipConditionAttribute(OperatingSystems.Linux | OperatingSystems.MacOSX, OperatingSystems.MacOSX); - - // Assert - Assert.False(osSkipAttributeLinux.IsMet); - Assert.False(osSkipAttributeMacOSX.IsMet); - } - - [Fact] - public void Skips_BothMacOSXAndWindows() - { - // Act - var osSkipAttribute = new OSSkipConditionAttribute(OperatingSystems.Windows | OperatingSystems.MacOSX, OperatingSystems.Windows); - var osSkipAttributeMacOSX = new OSSkipConditionAttribute(OperatingSystems.Windows | OperatingSystems.MacOSX, OperatingSystems.MacOSX); - - // Assert - Assert.False(osSkipAttribute.IsMet); - Assert.False(osSkipAttributeMacOSX.IsMet); - } - - [Fact] - public void Skips_BothWindowsAndLinux() - { - // Act - var osSkipAttribute = new OSSkipConditionAttribute(OperatingSystems.Linux | OperatingSystems.Windows, OperatingSystems.Windows); - var osSkipAttributeLinux = new OSSkipConditionAttribute(OperatingSystems.Linux | OperatingSystems.Windows, OperatingSystems.Linux); - - // Assert - Assert.False(osSkipAttribute.IsMet); - Assert.False(osSkipAttributeLinux.IsMet); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionTest.cs deleted file mode 100644 index a058ade..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/OSSkipConditionTest.cs +++ /dev/null @@ -1,105 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class OSSkipConditionTest - { - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux)] - public void TestSkipLinux() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Linux), - "Test should not be running on Linux"); - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.MacOSX)] - public void TestSkipMacOSX() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.OSX), - "Test should not be running on MacOSX."); - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Windows)] - public void TestSkipWindows() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows), - "Test should not be running on Windows."); - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - public void TestSkipLinuxAndMacOSX() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Linux), - "Test should not be running on Linux."); - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.OSX), - "Test should not be running on MacOSX."); - } - - [ConditionalTheory] - [OSSkipCondition(OperatingSystems.Linux)] - [InlineData(1)] - public void TestTheorySkipLinux(int arg) - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Linux), - "Test should not be running on Linux"); - } - - [ConditionalTheory] - [OSSkipCondition(OperatingSystems.MacOSX)] - [InlineData(1)] - public void TestTheorySkipMacOS(int arg) - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.OSX), - "Test should not be running on MacOSX."); - } - - [ConditionalTheory] - [OSSkipCondition(OperatingSystems.Windows)] - [InlineData(1)] - public void TestTheorySkipWindows(int arg) - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows), - "Test should not be running on Windows."); - } - - [ConditionalTheory] - [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX)] - [InlineData(1)] - public void TestTheorySkipLinuxAndMacOSX(int arg) - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Linux), - "Test should not be running on Linux."); - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.OSX), - "Test should not be running on MacOSX."); - } - } - - [OSSkipCondition(OperatingSystems.Windows)] - public class OSSkipConditionClassTest - { - [ConditionalFact] - public void TestSkipClassWindows() - { - Assert.False( - RuntimeInformation.IsOSPlatform(OSPlatform.Windows), - "Test should not be running on Windows."); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/Properties/AssemblyInfo.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/Properties/AssemblyInfo.cs deleted file mode 100644 index 0f8d3c8..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Testing; -using Xunit; - -[assembly: Repeat(1)] -[assembly: AssemblyFixture(typeof(TestAssemblyFixture))] -[assembly: TestFramework("Microsoft.AspNetCore.Testing.AspNetTestFramework", "Microsoft.AspNetCore.Testing")] diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/RepeatTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/RepeatTest.cs deleted file mode 100644 index e5e1d5d..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/RepeatTest.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - [Repeat] - public class RepeatTest - { - public static int _runCount = 0; - - [Fact] - [Repeat(5)] - public void RepeatLimitIsSetCorrectly() - { - Assert.Equal(5, RepeatContext.Current.Limit); - } - - [Fact] - [Repeat(5)] - public void RepeatRunsTestSpecifiedNumberOfTimes() - { - Assert.Equal(RepeatContext.Current.CurrentIteration, _runCount); - _runCount++; - } - - [Fact] - public void RepeatCanBeSetOnClass() - { - Assert.Equal(10, RepeatContext.Current.Limit); - } - } - - public class LoggedTestXunitRepeatAssemblyTests - { - [Fact] - public void RepeatCanBeSetOnAssembly() - { - Assert.Equal(1, RepeatContext.Current.Limit); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ReplaceCultureAttributeTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ReplaceCultureAttributeTest.cs deleted file mode 100644 index ff6740b..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/ReplaceCultureAttributeTest.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Globalization; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class RepalceCultureAttributeTest - { - [Fact] - public void DefaultsTo_EnGB_EnUS() - { - // Arrange - var culture = new CultureInfo("en-GB"); - var uiCulture = new CultureInfo("en-US"); - - // Act - var replaceCulture = new ReplaceCultureAttribute(); - - // Assert - Assert.Equal(culture, replaceCulture.Culture); - Assert.Equal(uiCulture, replaceCulture.UICulture); - } - - [Fact] - public void UsesSuppliedCultureAndUICulture() - { - // Arrange - var culture = "de-DE"; - var uiCulture = "fr-CA"; - - // Act - var replaceCulture = new ReplaceCultureAttribute(culture, uiCulture); - - // Assert - Assert.Equal(new CultureInfo(culture), replaceCulture.Culture); - Assert.Equal(new CultureInfo(uiCulture), replaceCulture.UICulture); - } - - [Fact] - public void BeforeAndAfterTest_ReplacesCulture() - { - // Arrange - var originalCulture = CultureInfo.CurrentCulture; - var originalUICulture = CultureInfo.CurrentUICulture; - var culture = "de-DE"; - var uiCulture = "fr-CA"; - var replaceCulture = new ReplaceCultureAttribute(culture, uiCulture); - - // Act - replaceCulture.Before(methodUnderTest: null); - - // Assert - Assert.Equal(new CultureInfo(culture), CultureInfo.CurrentCulture); - Assert.Equal(new CultureInfo(uiCulture), CultureInfo.CurrentUICulture); - - // Act - replaceCulture.After(methodUnderTest: null); - - // Assert - Assert.Equal(originalCulture, CultureInfo.CurrentCulture); - Assert.Equal(originalUICulture, CultureInfo.CurrentUICulture); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/SkipOnCITests.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/SkipOnCITests.cs deleted file mode 100644 index ee511c2..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/SkipOnCITests.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.AspNetCore.Testing; -using Xunit; - -namespace Microsoft.AspNetCore.Testing.Tests -{ - public class SkipOnCITests - { - [ConditionalFact] - [SkipOnCI] - public void AlwaysSkipOnCI() - { - if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HELIX")) || !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AGENT_OS"))) - { - throw new Exception("Flaky!"); - } - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TaskExtensionsTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TaskExtensionsTest.cs deleted file mode 100644 index d9f4bbe..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TaskExtensionsTest.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class TaskExtensionsTest - { - [Fact] - public async Task TimeoutAfterTest() - { - await Assert.ThrowsAsync(async () => await Task.Delay(1000).TimeoutAfter(TimeSpan.FromMilliseconds(50))); - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestAssemblyFixture.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestAssemblyFixture.cs deleted file mode 100644 index 75dddd2..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestAssemblyFixture.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Testing -{ - public class TestAssemblyFixture - { - public int Count { get; set; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestCollectionFixture.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestCollectionFixture.cs deleted file mode 100644 index 7fed042..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestCollectionFixture.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Testing -{ - public class TestCollectionFixture - { - public int Count { get; set; } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestContextTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestContextTest.cs deleted file mode 100644 index 7a81f37..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestContextTest.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class TestContextTest : ITestMethodLifecycle - { - public TestContext Context { get; private set; } - - [Fact] - public void FullName_IsUsed_ByDefault() - { - Assert.Equal(GetType().FullName, Context.FileOutput.TestClassName); - } - - Task ITestMethodLifecycle.OnTestStartAsync(TestContext context, CancellationToken cancellationToken) - { - Context = context; - return Task.CompletedTask; - } - - Task ITestMethodLifecycle.OnTestEndAsync(TestContext context, Exception exception, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } - } -} - -namespace Microsoft.AspNetCore.Testing.Tests -{ - public class TestContextNameShorteningTest : ITestMethodLifecycle - { - public TestContext Context { get; private set; } - - [Fact] - public void NameIsShortenedWhenAssemblyNameIsAPrefix() - { - Assert.Equal(GetType().Name, Context.FileOutput.TestClassName); - } - - Task ITestMethodLifecycle.OnTestStartAsync(TestContext context, CancellationToken cancellationToken) - { - Context = context; - return Task.CompletedTask; - } - - Task ITestMethodLifecycle.OnTestEndAsync(TestContext context, Exception exception, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } - } -} - -namespace Microsoft.AspNetCore.Testing -{ - [ShortClassName] - public class TestContextTestClassShortNameAttributeTest : ITestMethodLifecycle - { - public TestContext Context { get; private set; } - - [Fact] - public void ShortClassNameUsedWhenShortClassNameAttributeSpecified() - { - Assert.Equal(GetType().Name, Context.FileOutput.TestClassName); - } - - Task ITestMethodLifecycle.OnTestStartAsync(TestContext context, CancellationToken cancellationToken) - { - Context = context; - return Task.CompletedTask; - } - - Task ITestMethodLifecycle.OnTestEndAsync(TestContext context, Exception exception, CancellationToken cancellationToken) - { - return Task.CompletedTask; - } - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPathUtilitiesTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPathUtilitiesTest.cs deleted file mode 100644 index 9810db9..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPathUtilitiesTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class TestPathUtilitiesTest - { - // Entire test pending removal - see https://github.com/dotnet/extensions/issues/1697 -#pragma warning disable 0618 - - [Fact] - public void GetSolutionRootDirectory_ResolvesSolutionRoot() - { - // Directory.GetCurrentDirectory() gives: - // Testing\test\Microsoft.AspNetCore.Testing.Tests\bin\Debug\netcoreapp2.0 - // Testing\test\Microsoft.AspNetCore.Testing.Tests\bin\Debug\net461 - // Testing\test\Microsoft.AspNetCore.Testing.Tests\bin\Debug\net46 - var expectedPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..", "..", "..", "..", "..")); - - Assert.Equal(expectedPath, TestPathUtilities.GetSolutionRootDirectory("Extensions")); - } - - [Fact] - public void GetSolutionRootDirectory_Throws_IfNotFound() - { - var exception = Assert.Throws(() => TestPathUtilities.GetSolutionRootDirectory("NotTesting")); - Assert.Equal($"Solution file NotTesting.sln could not be found in {AppContext.BaseDirectory} or its parent directories.", exception.Message); - } -#pragma warning restore 0618 - } -} diff --git a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPlatformHelperTest.cs b/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPlatformHelperTest.cs deleted file mode 100644 index dcecc6b..0000000 --- a/src/libraries/Common/tests/Extensions/TestingUtils/Microsoft.AspNetCore.Testing/test/TestPlatformHelperTest.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Testing; -using Xunit; - -namespace Microsoft.AspNetCore.Testing -{ - public class TestPlatformHelperTest - { - [ConditionalFact] - [OSSkipCondition(OperatingSystems.MacOSX)] - [OSSkipCondition(OperatingSystems.Windows)] - public void IsLinux_TrueOnLinux() - { - Assert.True(TestPlatformHelper.IsLinux); - Assert.False(TestPlatformHelper.IsMac); - Assert.False(TestPlatformHelper.IsWindows); - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux)] - [OSSkipCondition(OperatingSystems.Windows)] - public void IsMac_TrueOnMac() - { - Assert.False(TestPlatformHelper.IsLinux); - Assert.True(TestPlatformHelper.IsMac); - Assert.False(TestPlatformHelper.IsWindows); - } - - [ConditionalFact] - [OSSkipCondition(OperatingSystems.Linux)] - [OSSkipCondition(OperatingSystems.MacOSX)] - public void IsWindows_TrueOnWindows() - { - Assert.False(TestPlatformHelper.IsLinux); - Assert.False(TestPlatformHelper.IsMac); - Assert.True(TestPlatformHelper.IsWindows); - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CLR | RuntimeFrameworks.CoreCLR | RuntimeFrameworks.None)] - public void IsMono_TrueOnMono() - { - Assert.True(TestPlatformHelper.IsMono); - } - - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] - public void IsMono_FalseElsewhere() - { - Assert.False(TestPlatformHelper.IsMono); - } - } -} diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/Microsoft.Extensions.Caching.Memory.Tests.csproj b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/Microsoft.Extensions.Caching.Memory.Tests.csproj index d72fff1..7046da2 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/Microsoft.Extensions.Caching.Memory.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/Microsoft.Extensions.Caching.Memory.Tests.csproj @@ -6,13 +6,6 @@ - - - - - diff --git a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/TimeExpirationTests.cs b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/TimeExpirationTests.cs index b35d42c..4a26ad0 100644 --- a/src/libraries/Microsoft.Extensions.Caching.Memory/tests/TimeExpirationTests.cs +++ b/src/libraries/Microsoft.Extensions.Caching.Memory/tests/TimeExpirationTests.cs @@ -3,7 +3,6 @@ using System; using System.Threading; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Internal; using Xunit; @@ -97,14 +96,8 @@ namespace Microsoft.Extensions.Caching.Memory var key = "myKey"; var value = new object(); - ExceptionAssert.ThrowsArgumentOutOfRange(() => - { - var result = cache.Set(key, value, new MemoryCacheEntryOptions() - .SetAbsoluteExpiration(TimeSpan.FromMinutes(-1))); - }, - nameof(MemoryCacheEntryOptions.AbsoluteExpirationRelativeToNow), - "The relative expiration value must be positive.", - TimeSpan.FromMinutes(-1)); + AssertExtensions.Throws(nameof(MemoryCacheEntryOptions.AbsoluteExpirationRelativeToNow), () => + cache.Set(key, value, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromMinutes(-1)))); } [Fact] @@ -115,13 +108,8 @@ namespace Microsoft.Extensions.Caching.Memory var key = "myKey"; var value = new object(); - ExceptionAssert.ThrowsArgumentOutOfRange(() => - { - var result = cache.Set(key, value, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.Zero)); - }, - nameof(MemoryCacheEntryOptions.AbsoluteExpirationRelativeToNow), - "The relative expiration value must be positive.", - TimeSpan.Zero); + AssertExtensions.Throws(nameof(MemoryCacheEntryOptions.AbsoluteExpirationRelativeToNow), () => + cache.Set(key, value, new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.Zero))); } [Fact] @@ -154,14 +142,8 @@ namespace Microsoft.Extensions.Caching.Memory var key = "myKey"; var value = new object(); - ExceptionAssert.ThrowsArgumentOutOfRange(() => - { - var result = cache.Set(key, value, new MemoryCacheEntryOptions() - .SetSlidingExpiration(TimeSpan.FromMinutes(-1))); - }, - nameof(MemoryCacheEntryOptions.SlidingExpiration), - "The sliding expiration value must be positive.", - TimeSpan.FromMinutes(-1)); + AssertExtensions.Throws(nameof(MemoryCacheEntryOptions.SlidingExpiration), () => + cache.Set(key, value, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(-1)))); } [Fact] @@ -172,14 +154,8 @@ namespace Microsoft.Extensions.Caching.Memory var key = "myKey"; var value = new object(); - ExceptionAssert.ThrowsArgumentOutOfRange(() => - { - var result = cache.Set(key, value, new MemoryCacheEntryOptions() - .SetSlidingExpiration(TimeSpan.Zero)); - }, - nameof(MemoryCacheEntryOptions.SlidingExpiration), - "The sliding expiration value must be positive.", - TimeSpan.Zero); + AssertExtensions.Throws(nameof(MemoryCacheEntryOptions.SlidingExpiration), () => + cache.Set(key, value, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.Zero))); } [Fact] diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/Microsoft.Extensions.Configuration.Xml.Tests.csproj b/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/Microsoft.Extensions.Configuration.Xml.Tests.csproj index 7a98c89..40c5a18 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/Microsoft.Extensions.Configuration.Xml.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/Microsoft.Extensions.Configuration.Xml.Tests.csproj @@ -12,19 +12,6 @@ Link="Microsoft.Extensions.Configuration\tests\Common\ConfigurationProviderExtensions.cs" /> - - - - - - - - diff --git a/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs b/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs index cfff1fe..b9c59d9 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Xml/tests/XmlConfigurationTest.cs @@ -5,8 +5,8 @@ using System; using System.IO; using System.Security.Cryptography; using System.Security.Cryptography.Xml; +using System.Tests; using System.Xml; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Configuration.Test; using Xunit; @@ -318,7 +318,6 @@ namespace Microsoft.Extensions.Configuration.Xml.Test } [Fact] - [ReplaceCulture] public void ThrowExceptionWhenFindDTD() { var xml = @@ -339,15 +338,19 @@ namespace Microsoft.Extensions.Configuration.Xml.Test "; - var xmlConfigSrc = new XmlConfigurationProvider(new XmlConfigurationSource()); - var isMono = Type.GetType("Mono.Runtime") != null; - var expectedMsg = isMono ? "Document Type Declaration (DTD) is prohibited in this XML. Line 1, position 10." : "For security reasons DTD is prohibited in this XML document. " - + "To enable DTD processing set the DtdProcessing property on XmlReaderSettings " - + "to Parse and pass the settings into XmlReader.Create method."; - var exception = Assert.Throws(() => xmlConfigSrc.Load(TestStreamHelpers.StringToStream(xml))); + using (new ThreadCultureChange("en-GB")) + { + var xmlConfigSrc = new XmlConfigurationProvider(new XmlConfigurationSource()); + var isMono = Type.GetType("Mono.Runtime") != null; + var expectedMsg = isMono ? "Document Type Declaration (DTD) is prohibited in this XML. Line 1, position 10." : "For security reasons DTD is prohibited in this XML document. " + + "To enable DTD processing set the DtdProcessing property on XmlReaderSettings " + + "to Parse and pass the settings into XmlReader.Create method."; + + var exception = Assert.Throws(() => xmlConfigSrc.Load(TestStreamHelpers.StringToStream(xml))); - Assert.Equal(expectedMsg, exception.Message); + Assert.Equal(expectedMsg, exception.Message); + } } [Fact] @@ -433,7 +436,6 @@ namespace Microsoft.Extensions.Configuration.Xml.Test [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] - [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void LoadKeyValuePairsFromValidEncryptedXml() { var xml = @" diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj index d741185..9357bad 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj @@ -12,10 +12,6 @@ - - diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/Microsoft.Extensions.DependencyInjection.Tests.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/Microsoft.Extensions.DependencyInjection.Tests.csproj index 5dcd273..762664f 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/Microsoft.Extensions.DependencyInjection.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/Microsoft.Extensions.DependencyInjection.Tests.csproj @@ -6,10 +6,6 @@ - - diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionServiceExtensionsTest.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionServiceExtensionsTest.cs index cdecbb6..3acb7de 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionServiceExtensionsTest.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceCollectionServiceExtensionsTest.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Specification.Fakes; using Xunit; @@ -343,10 +342,7 @@ namespace Microsoft.Extensions.DependencyInjection // Arrange var collection = new ServiceCollection(); - // Act & Assert - ExceptionAssert.ThrowsArgument( - () => collection.TryAddEnumerable(descriptor), - "descriptor", + AssertExtensions.ThrowsContains(() => collection.TryAddEnumerable(descriptor), string.Format(@"Implementation type cannot be '{0}' because it is indistinguishable from other services registered for '{1}'.", implementationType, serviceType)); } diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderServiceExtensionsTest.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderServiceExtensionsTest.cs index 015350e..9bed4bf 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderServiceExtensionsTest.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceProviderServiceExtensionsTest.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.AspNetCore.Testing; using Xunit; namespace Microsoft.Extensions.DependencyInjection @@ -44,7 +43,7 @@ namespace Microsoft.Extensions.DependencyInjection var serviceProvider = CreateTestServiceProvider(0); // Act + Assert - ExceptionAssert.Throws(() => serviceProvider.GetRequiredService(), + AssertExtensions.Throws(() => serviceProvider.GetRequiredService(), $"No service for type '{typeof(IFoo)}' has been registered."); } @@ -55,7 +54,7 @@ namespace Microsoft.Extensions.DependencyInjection var serviceProvider = new RequiredServiceSupportingProvider(); // Act + Assert - ExceptionAssert.Throws(() => serviceProvider.GetRequiredService()); + AssertExtensions.Throws(() => serviceProvider.GetRequiredService()); } [Fact] @@ -65,7 +64,7 @@ namespace Microsoft.Extensions.DependencyInjection var serviceProvider = CreateTestServiceProvider(0); // Act + Assert - ExceptionAssert.Throws(() => serviceProvider.GetRequiredService(typeof(IFoo)), + AssertExtensions.Throws(() => serviceProvider.GetRequiredService(typeof(IFoo)), $"No service for type '{typeof(IFoo)}' has been registered."); } @@ -76,7 +75,7 @@ namespace Microsoft.Extensions.DependencyInjection var serviceProvider = new RequiredServiceSupportingProvider(); // Act + Assert - ExceptionAssert.Throws(() => serviceProvider.GetRequiredService(typeof(IFoo))); + AssertExtensions.Throws(() => serviceProvider.GetRequiredService(typeof(IFoo))); } [Fact] diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceTableTest.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceTableTest.cs index 198308d..b2843e3 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceTableTest.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/ServiceTableTest.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Microsoft.AspNetCore.Testing; using Xunit; namespace Microsoft.Extensions.DependencyInjection.ServiceLookup @@ -23,10 +22,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup }; // Act and Assert - ExceptionAssert.ThrowsArgument( - () => new CallSiteFactory(serviceDescriptors), - "descriptors", - $"Open generic service type '{typeof(IList<>)}' requires registering an open generic implementation type."); + AssertExtensions.Throws("descriptors", () => new CallSiteFactory(serviceDescriptors)); } public static TheoryData Constructor_WithInstance_ThrowsIfServiceTypeIsOpenGenericData => @@ -48,10 +44,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup }; // Act and Assert - var ex = ExceptionAssert.ThrowsArgument( - () => new CallSiteFactory(serviceDescriptors), - "descriptors", - $"Open generic service type '{typeof(IEnumerable<>)}' requires registering an open generic implementation type."); + AssertExtensions.Throws("descriptors", () => new CallSiteFactory(serviceDescriptors)); } [Fact] @@ -64,10 +57,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup }; // Act and Assert - var ex = ExceptionAssert.ThrowsArgument( - () => new CallSiteFactory(serviceDescriptors), - "descriptors", - $"Open generic service type '{typeof(Tuple<>)}' requires registering an open generic implementation type."); + AssertExtensions.Throws("descriptors", () => new CallSiteFactory(serviceDescriptors)); } } } diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj index b59f590..2f22d08 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/Microsoft.Extensions.FileProviders.Physical.Tests.csproj @@ -7,10 +7,8 @@ - - + diff --git a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs index 819a30a..0d9fb95 100644 --- a/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs +++ b/src/libraries/Microsoft.Extensions.FileProviders.Physical/tests/PhysicalFileProviderTests.cs @@ -6,7 +6,6 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.FileProviders.Internal; using Microsoft.Extensions.FileProviders.Physical; using Microsoft.Extensions.Primitives; diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/SelfHostDeployer.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/SelfHostDeployer.cs index b609679..4dd4a4c 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/SelfHostDeployer.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/SelfHostDeployer.cs @@ -8,7 +8,6 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Logging; namespace Microsoft.Extensions.Hosting.IntegrationTesting diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj index 2d67db8..ffd54fef 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/Microsoft.Extensions.Hosting.Functional.Tests.csproj @@ -8,8 +8,6 @@ - + + + + diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs index 50dfdad..c9a4af0 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/ShutdownTests.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Threading.Tasks; -using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Hosting.IntegrationTesting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Test; diff --git a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj index 908e9d0..c729cbe 100644 --- a/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.Logging/tests/DI.Common/Common/tests/Microsoft.Extensions.Logging.Testing.Tests.csproj @@ -5,8 +5,6 @@ -