diff --git a/eng/Versions.props b/eng/Versions.props
index f42eb55d01b..7fbbfaafa80 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -225,6 +225,7 @@
Starting with 3.0.0, xunit.runner.visualstudio only supports net472, but we target net462
-->
2.8.2
+ 9.0.0-beta.25562.4
9.7.0
1.67.0-preview
diff --git a/eng/packages/TestOnly.props b/eng/packages/TestOnly.props
index 513f82789d9..5e6188a0812 100644
--- a/eng/packages/TestOnly.props
+++ b/eng/packages/TestOnly.props
@@ -10,6 +10,7 @@
+
diff --git a/scripts/Slngen.Tests.ps1 b/scripts/Slngen.Tests.ps1
index 156ade6154e..9c38eca5040 100644
--- a/scripts/Slngen.Tests.ps1
+++ b/scripts/Slngen.Tests.ps1
@@ -19,8 +19,8 @@ Describe "Slngen.ps1" {
$DefaultExcludePath = "--exclude src\Tools\MutationTesting\samples\ --exclude src\Templates\templates"
$DefaultSlnPath = '"' + (Join-Path -Path (Get-Location) -ChildPath "SDK.sln") + '"'
- $PollyKeywordGlobs = 'test/TestUtilities/TestUtilities.csproj src/**/*Polly*/**/*.*sproj test/**/*Polly*/**/*.*sproj bench/**/*Polly*/**/*.*sproj int_test/**/*Polly*/**/*.*sproj docs/**/*Polly*/**/*.*sproj'
- $PollyHttpKeywordsGlobs = 'test/TestUtilities/TestUtilities.csproj src/**/*Polly*/**/*.*sproj test/**/*Polly*/**/*.*sproj bench/**/*Polly*/**/*.*sproj int_test/**/*Polly*/**/*.*sproj docs/**/*Polly*/**/*.*sproj src/**/*Http*/**/*.*sproj test/**/*Http*/**/*.*sproj bench/**/*Http*/**/*.*sproj int_test/**/*Http*/**/*.*sproj docs/**/*Http*/**/*.*sproj'
+ $PollyKeywordGlobs = 'src/**/*Polly*/**/*.*sproj test/**/*Polly*/**/*.*sproj bench/**/*Polly*/**/*.*sproj int_test/**/*Polly*/**/*.*sproj docs/**/*Polly*/**/*.*sproj'
+ $PollyHttpKeywordsGlobs = 'src/**/*Polly*/**/*.*sproj test/**/*Polly*/**/*.*sproj bench/**/*Polly*/**/*.*sproj int_test/**/*Polly*/**/*.*sproj docs/**/*Polly*/**/*.*sproj src/**/*Http*/**/*.*sproj test/**/*Http*/**/*.*sproj bench/**/*Http*/**/*.*sproj int_test/**/*Http*/**/*.*sproj docs/**/*Http*/**/*.*sproj'
}
Context "Invoke-SlngenExe with test cases from examples" {
diff --git a/scripts/Slngen.ps1 b/scripts/Slngen.ps1
index 1980f458e94..5924fcb03ea 100755
--- a/scripts/Slngen.ps1
+++ b/scripts/Slngen.ps1
@@ -169,10 +169,6 @@ Push-Location $RepositoryPath
try {
[System.Collections.ArrayList]$Globs = @()
- if (!$OnlySources) {
- $Globs += "test/TestUtilities/TestUtilities.csproj"
- }
-
if (!$All) {
foreach ($Keyword in $Keywords) {
$Globs += "src/**/*$($Keyword)*/**/*.*sproj"
diff --git a/test/Libraries/Microsoft.AspNetCore.Testing.Tests/FakeCertificateFactoryTests.cs b/test/Libraries/Microsoft.AspNetCore.Testing.Tests/FakeCertificateFactoryTests.cs
index 1da6dc74ddc..227485ee2ff 100644
--- a/test/Libraries/Microsoft.AspNetCore.Testing.Tests/FakeCertificateFactoryTests.cs
+++ b/test/Libraries/Microsoft.AspNetCore.Testing.Tests/FakeCertificateFactoryTests.cs
@@ -4,7 +4,6 @@
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.AspNetCore.Testing.Test;
@@ -23,8 +22,8 @@ public void Create_CreatesCertificate()
Assert.False(certificate.Extensions.OfType().Single().Critical);
}
- [ConditionalTheory]
- [OSSkipCondition(OperatingSystems.Linux)]
+ [PlatformSpecific(~TestPlatforms.Linux)]
+ [Theory]
[InlineData(false)]
[InlineData(true)]
public void GenerateRsa_RunsOnWindows_GeneratesRsa(bool runsOnWindows)
@@ -32,8 +31,8 @@ public void GenerateRsa_RunsOnWindows_GeneratesRsa(bool runsOnWindows)
Assert.NotNull(FakeSslCertificateFactory.GenerateRsa(runsOnWindows));
}
- [ConditionalFact]
- [OSSkipCondition(OperatingSystems.Windows)]
+ [PlatformSpecific(~TestPlatforms.Windows)]
+ [Fact]
public void GenerateRsa_DoesNotRunOnWindows_GeneratesRsa()
{
Assert.NotNull(FakeSslCertificateFactory.GenerateRsa(runsOnWindows: false));
diff --git a/test/Libraries/Microsoft.AspNetCore.Testing.Tests/Microsoft.AspNetCore.Testing.Tests.csproj b/test/Libraries/Microsoft.AspNetCore.Testing.Tests/Microsoft.AspNetCore.Testing.Tests.csproj
index 11d60ebbaba..14a3f443e5b 100644
--- a/test/Libraries/Microsoft.AspNetCore.Testing.Tests/Microsoft.AspNetCore.Testing.Tests.csproj
+++ b/test/Libraries/Microsoft.AspNetCore.Testing.Tests/Microsoft.AspNetCore.Testing.Tests.csproj
@@ -11,6 +11,10 @@
-
+
+
+
+
+
diff --git a/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Microsoft.Extensions.AI.Abstractions.Tests.csproj b/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Microsoft.Extensions.AI.Abstractions.Tests.csproj
index 4c275e54993..353f87f9260 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Microsoft.Extensions.AI.Abstractions.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Microsoft.Extensions.AI.Abstractions.Tests.csproj
@@ -29,6 +29,7 @@
+
@@ -37,6 +38,5 @@
-
diff --git a/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs b/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs
index 8ebc20b957e..ebe3a4f91e8 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs
@@ -15,7 +15,6 @@
using System.Text.Json.Serialization.Metadata;
using System.Threading;
using Microsoft.Extensions.AI.JsonSchemaExporter;
-using Microsoft.TestUtilities;
using Xunit;
#pragma warning disable SA1114 // parameter list should follow declaration
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/AgentQualityEvaluatorTests.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/AgentQualityEvaluatorTests.cs
index 238b805e867..5f99e217489 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/AgentQualityEvaluatorTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/AgentQualityEvaluatorTests.cs
@@ -7,13 +7,12 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.AI.Evaluation.Quality;
using Microsoft.Extensions.AI.Evaluation.Reporting;
using Microsoft.Extensions.AI.Evaluation.Reporting.Storage;
using Microsoft.Extensions.AI.Evaluation.Tests;
-using Microsoft.TestUtilities;
using Xunit;
-
namespace Microsoft.Extensions.AI.Evaluation.Integration.Tests;
[Experimental("AIEVAL001")]
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Microsoft.Extensions.AI.Evaluation.Integration.Tests.csproj b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Microsoft.Extensions.AI.Evaluation.Integration.Tests.csproj
index 8ee7f39ee1c..4bcc5f518fa 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Microsoft.Extensions.AI.Evaluation.Integration.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/Microsoft.Extensions.AI.Evaluation.Integration.Tests.csproj
@@ -21,6 +21,7 @@
+
@@ -35,7 +36,6 @@
-
\ No newline at end of file
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/NLPEvaluatorTests.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/NLPEvaluatorTests.cs
index 9cd593a647a..774874882e4 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/NLPEvaluatorTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/NLPEvaluatorTests.cs
@@ -5,12 +5,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.AI.Evaluation.NLP;
using Microsoft.Extensions.AI.Evaluation.Reporting;
using Microsoft.Extensions.AI.Evaluation.Reporting.Storage;
-using Microsoft.TestUtilities;
using Xunit;
-
namespace Microsoft.Extensions.AI.Evaluation.Integration.Tests;
[Experimental("AIEVAL001")]
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/QualityEvaluatorTests.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/QualityEvaluatorTests.cs
index fde342a4161..0ece7dfddd9 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/QualityEvaluatorTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/QualityEvaluatorTests.cs
@@ -6,13 +6,12 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.AI.Evaluation.Quality;
using Microsoft.Extensions.AI.Evaluation.Reporting;
using Microsoft.Extensions.AI.Evaluation.Reporting.Storage;
using Microsoft.Extensions.AI.Evaluation.Tests;
-using Microsoft.TestUtilities;
using Xunit;
-
namespace Microsoft.Extensions.AI.Evaluation.Integration.Tests;
[Experimental("AIEVAL001")]
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/SafetyEvaluatorTests.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/SafetyEvaluatorTests.cs
index 68b4a9d8ce0..b5b641f55c9 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/SafetyEvaluatorTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Integration.Tests/SafetyEvaluatorTests.cs
@@ -7,13 +7,13 @@
using System.Linq;
using System.Threading.Tasks;
using Azure.Identity;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.AI.Evaluation.Quality;
using Microsoft.Extensions.AI.Evaluation.Reporting;
using Microsoft.Extensions.AI.Evaluation.Reporting.Storage;
using Microsoft.Extensions.AI.Evaluation.Safety;
using Microsoft.Extensions.AI.Evaluation.Tests;
using Microsoft.Extensions.AI.Evaluation.Utilities;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.AI.Evaluation.Integration.Tests;
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/EmbeddingTests.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/EmbeddingTests.cs
index bf00efc6471..ac345200269 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/EmbeddingTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/EmbeddingTests.cs
@@ -2,8 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.AI.Evaluation.Reporting.Formats.Html;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.AI.Evaluation.Reporting.Tests;
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/Microsoft.Extensions.AI.Evaluation.Reporting.Tests.csproj b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/Microsoft.Extensions.AI.Evaluation.Reporting.Tests.csproj
index 44b7e2f561b..73114273cd9 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/Microsoft.Extensions.AI.Evaluation.Reporting.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/Microsoft.Extensions.AI.Evaluation.Reporting.Tests.csproj
@@ -10,6 +10,7 @@
+
@@ -17,7 +18,6 @@
-
\ No newline at end of file
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResponseCacheTester.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResponseCacheTester.cs
index 50793dfdb66..ed82e91e3f1 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResponseCacheTester.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResponseCacheTester.cs
@@ -4,8 +4,8 @@
using System;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.Caching.Distributed;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.AI.Evaluation.Reporting.Tests;
diff --git a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResultStoreTester.cs b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResultStoreTester.cs
index 995b77a8c5e..32089e1a4d7 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResultStoreTester.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ResultStoreTester.cs
@@ -6,7 +6,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace Microsoft.Extensions.AI.Evaluation.Reporting.Tests;
diff --git a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs
index 992e86a1184..8d9a53ba45b 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ChatClientIntegrationTests.cs
@@ -14,11 +14,12 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
+
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
-using Microsoft.TestUtilities;
using OpenTelemetry.Trace;
using Xunit;
diff --git a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/EmbeddingGeneratorIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/EmbeddingGeneratorIntegrationTests.cs
index 20423ae9e8b..54416b26e5e 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/EmbeddingGeneratorIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/EmbeddingGeneratorIntegrationTests.cs
@@ -14,9 +14,10 @@
using System.Numerics.Tensors;
#endif
using System.Threading.Tasks;
+
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
-using Microsoft.TestUtilities;
using OpenTelemetry.Trace;
using Xunit;
diff --git a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratingChatClientIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratingChatClientIntegrationTests.cs
index 2cbdcd96abf..a4a12a44bc7 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratingChatClientIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratingChatClientIntegrationTests.cs
@@ -7,7 +7,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
#pragma warning disable CA2000 // Dispose objects before losing scope
diff --git a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratorIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratorIntegrationTests.cs
index 76b08941bc5..78398681dea 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratorIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratorIntegrationTests.cs
@@ -5,7 +5,7 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
#pragma warning disable CA2214 // Do not call overridable methods in constructors
diff --git a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/Microsoft.Extensions.AI.Integration.Tests.csproj b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/Microsoft.Extensions.AI.Integration.Tests.csproj
index bd6c6b9ba2f..9c65fbc3414 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/Microsoft.Extensions.AI.Integration.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/Microsoft.Extensions.AI.Integration.Tests.csproj
@@ -37,6 +37,7 @@
+
@@ -52,6 +53,5 @@
-
diff --git a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/SpeechToTextClientIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/SpeechToTextClientIntegrationTests.cs
index f0ea6c1790e..969fce171a3 100644
--- a/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/SpeechToTextClientIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.Integration.Tests/SpeechToTextClientIntegrationTests.cs
@@ -6,7 +6,7 @@
using System.IO;
using System.Text;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
#pragma warning disable CA2214 // Do not call overridable methods in constructors
diff --git a/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpChatClientIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpChatClientIntegrationTests.cs
index 28d3e21fd65..807f7e5c086 100644
--- a/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpChatClientIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpChatClientIntegrationTests.cs
@@ -6,7 +6,7 @@
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using OllamaSharp;
using Xunit;
diff --git a/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpEmbeddingGeneratorIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpEmbeddingGeneratorIntegrationTests.cs
index f7775143c36..b5a21aa78ec 100644
--- a/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpEmbeddingGeneratorIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.OllamaSharp.Integration.Tests/OllamaSharpEmbeddingGeneratorIntegrationTests.cs
@@ -3,7 +3,6 @@
using System;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
using OllamaSharp;
using Xunit;
diff --git a/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAssistantChatClientIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAssistantChatClientIntegrationTests.cs
index ef9d6063ddd..0c85ea5c23f 100644
--- a/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAssistantChatClientIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAssistantChatClientIntegrationTests.cs
@@ -12,7 +12,6 @@
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
using OpenAI.Assistants;
using Xunit;
diff --git a/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs b/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs
index 6a7f82302ea..ef00899dde3 100644
--- a/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs
+++ b/test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace Microsoft.Extensions.AI;
diff --git a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Microsoft.Extensions.DataIngestion.Tests.csproj b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Microsoft.Extensions.DataIngestion.Tests.csproj
index cc64014cad6..3d8bad77ca8 100644
--- a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Microsoft.Extensions.DataIngestion.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Microsoft.Extensions.DataIngestion.Tests.csproj
@@ -15,10 +15,10 @@
-
+
diff --git a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/DocumentReaderConformanceTests.cs b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/DocumentReaderConformanceTests.cs
index d4993ad2cea..ab7def685c3 100644
--- a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/DocumentReaderConformanceTests.cs
+++ b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/DocumentReaderConformanceTests.cs
@@ -7,8 +7,8 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.DotNet.XUnitExtensions;
using Microsoft.Extensions.DataIngestion.Tests.Utils;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.DataIngestion.Readers.Tests;
diff --git a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownConditionAttribute.cs b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownCondition.cs
similarity index 69%
rename from test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownConditionAttribute.cs
rename to test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownCondition.cs
index b0169a54c1c..81a9978cc25 100644
--- a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownConditionAttribute.cs
+++ b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownCondition.cs
@@ -5,21 +5,17 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
-using Microsoft.TestUtilities;
namespace Microsoft.Extensions.DataIngestion.Readers.Tests;
///
-/// This class exists because currently the local copy of can't ignore tests that throw .
+/// Helper class for checking if MarkItDown is installed.
///
-[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
-public class MarkItDownConditionAttribute : Attribute, ITestCondition
+public static class MarkItDownCondition
{
internal static readonly Lazy IsInstalled = new(CanInvokeMarkItDown);
- public bool IsMet => IsInstalled.Value;
-
- public string SkipReason => "MarkItDown is not installed or not accessible.";
+ public static bool IsMarkItDownInstalled => IsInstalled.Value;
private static bool CanInvokeMarkItDown()
{
diff --git a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownReaderTests.cs b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownReaderTests.cs
index e506ea15ca1..fc49c136781 100644
--- a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownReaderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownReaderTests.cs
@@ -4,18 +4,18 @@
using System;
using System.Linq;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
+using Microsoft.DotNet.XUnitExtensions;
using Xunit;
namespace Microsoft.Extensions.DataIngestion.Readers.Tests;
-[MarkItDownCondition]
+[ConditionalClass(typeof(MarkItDownCondition), nameof(MarkItDownCondition.IsMarkItDownInstalled))]
public class MarkItDownReaderTests : DocumentReaderConformanceTests
{
protected override IngestionDocumentReader CreateDocumentReader(bool extractImages = false)
- => MarkItDownConditionAttribute.IsInstalled.Value
- ? new MarkItDownReader(extractImages: extractImages)
- : throw new SkipTestException("MarkItDown is not installed");
+ => MarkItDownCondition.IsMarkItDownInstalled
+ ? new MarkItDownReader(extractImages: extractImages)
+ : throw new SkipTestException("MarkItDown is not installed");
protected override void SimpleAsserts(IngestionDocument document, string source, string expectedId)
{
diff --git a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkdownReaderTests.cs b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkdownReaderTests.cs
index dce6d996821..55a8994231e 100644
--- a/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkdownReaderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkdownReaderTests.cs
@@ -5,7 +5,6 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.DataIngestion.Readers.Tests;
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Linux/LinuxResourceHealthCheckTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Linux/LinuxResourceHealthCheckTests.cs
index 53bc425c6a8..86d986eafaf 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Linux/LinuxResourceHealthCheckTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Linux/LinuxResourceHealthCheckTests.cs
@@ -9,7 +9,6 @@
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux;
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Time.Testing;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
@@ -142,9 +141,9 @@ public class LinuxResourceHealthCheckTests
},
};
- [ConditionalTheory]
+ [Theory]
[MemberData(nameof(Data))]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux-specific test.")]
+ [PlatformSpecific(TestPlatforms.Linux)]
public async Task TestCpuAndMemoryChecks_WithMetrics(
HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory,
ResourceUsageThresholds cpuThresholds, ResourceUsageThresholds memoryThresholds,
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests.csproj b/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests.csproj
index dcd6d4e40db..6d5bd67b4af 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests.csproj
@@ -6,11 +6,11 @@
-
+
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/ResourceHealthCheckExtensionsTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/ResourceHealthCheckExtensionsTests.cs
index 2599be2dd9e..b60bf877896 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/ResourceHealthCheckExtensionsTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/ResourceHealthCheckExtensionsTests.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Threading.Tasks;
+
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring;
@@ -13,17 +14,16 @@
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Time.Testing;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
using static Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Interop.JobObjectInfo;
namespace Microsoft.Extensions.Diagnostics.HealthChecks.Test;
-[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
+[PlatformSpecific(~TestPlatforms.OSX)]
public class ResourceHealthCheckExtensionsTests
{
- [ConditionalFact]
+ [Fact]
public async Task AddResourceHealthCheck()
{
var dataTracker = new Mock();
@@ -464,9 +464,9 @@ public void TestNullChecks()
Assert.Throws(() => ((IHealthChecksBuilder)null!).AddResourceUtilizationHealthCheck((IConfigurationSection)null!));
}
- [ConditionalTheory]
+ [Theory]
[ClassData(typeof(HealthCheckTestData))]
- [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows-specific test.")]
+ [PlatformSpecific(TestPlatforms.Windows)]
public async Task TestCpuAndMemoryChecks_WithMetrics(
HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory,
ResourceUsageThresholds cpuThresholds, ResourceUsageThresholds memoryThresholds,
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs
index 1dd11c1f3bb..8335a9074f5 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs
@@ -19,15 +19,14 @@
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Time.Testing;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
+[PlatformSpecific(TestPlatforms.Linux)]
public sealed class AcceptanceTest
{
- [ConditionalFact]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
public void Adding_Linux_Resource_Utilization_Allows_To_Query_Snapshot_Provider()
{
using var services = new ServiceCollection()
@@ -40,8 +39,7 @@ public void Adding_Linux_Resource_Utilization_Allows_To_Query_Snapshot_Provider(
Assert.NotEqual(default, provider.GetSnapshot());
}
- [ConditionalFact]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
[SuppressMessage("Minor Code Smell", "S3257:Declarations and initializations should be as concise as possible", Justification = "Broken analyzer.")]
public void Adding_Linux_Resource_Utilization_Can_Be_Configured_With_Section()
{
@@ -70,8 +68,7 @@ public void Adding_Linux_Resource_Utilization_Can_Be_Configured_With_Section()
Assert.Equal(memoryRefresh, options.Value.MemoryConsumptionRefreshInterval);
}
- [ConditionalFact]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
public void Adding_Linux_Resource_Utilization_Can_Be_Configured_With_Action()
{
var cpuRefresh = TimeSpan.FromMinutes(13);
@@ -92,8 +89,7 @@ public void Adding_Linux_Resource_Utilization_Can_Be_Configured_With_Action()
Assert.Equal(memoryRefresh, options.Value.MemoryConsumptionRefreshInterval);
}
- [ConditionalFact]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
[SuppressMessage("Minor Code Smell", "S3257:Declarations and initializations should be as concise as possible", Justification = "Broken analyzer.")]
public void Adding_Linux_Resource_Utilization_With_Section_Registers_SnapshotProvider_Cgroupv1()
{
@@ -141,8 +137,7 @@ public void Adding_Linux_Resource_Utilization_With_Section_Registers_SnapshotPro
Assert.Equal(100_000UL, provider.Resources.MaximumMemoryInBytes);
}
- [ConditionalFact]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
[SuppressMessage("Minor Code Smell", "S3257:Declarations and initializations should be as concise as possible", Justification = "Broken analyzer.")]
public void Adding_Linux_Resource_Utilization_With_Section_Registers_SnapshotProvider_Cgroupv2()
{
@@ -189,9 +184,7 @@ public void Adding_Linux_Resource_Utilization_With_Section_Registers_SnapshotPro
Assert.Equal(100_000UL, provider.Resources.MaximumMemoryInBytes);
}
- [ConditionalFact]
- [CombinatorialData]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
public Task ResourceUtilizationTracker_And_Metrics_Report_Same_Values_With_Cgroupsv1()
{
var cpuRefresh = TimeSpan.FromMinutes(13);
@@ -287,9 +280,7 @@ public Task ResourceUtilizationTracker_And_Metrics_Report_Same_Values_With_Cgrou
return Task.CompletedTask;
}
- [ConditionalFact]
- [CombinatorialData]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
public Task ResourceUtilizationTracker_And_Metrics_Report_Same_Values_With_Cgroupsv2()
{
var cpuRefresh = TimeSpan.FromMinutes(13);
@@ -395,9 +386,7 @@ public Task ResourceUtilizationTracker_And_Metrics_Report_Same_Values_With_Cgrou
return Task.CompletedTask;
}
- [ConditionalFact]
- [CombinatorialData]
- [OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+ [Fact]
public Task ResourceUtilizationTracker_And_Metrics_Report_Same_Values_With_Cgroupsv2_Using_LinuxCalculationV2()
{
var fileSystem = new HardcodedValueFileSystem(new Dictionary
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/DiskStatsReaderTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/DiskStatsReaderTests.cs
index 1f7738bb030..15ca01d60d4 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/DiskStatsReaderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/DiskStatsReaderTests.cs
@@ -5,12 +5,11 @@
using System.IO;
using System.Linq;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Disk.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public class DiskStatsReaderTests
{
private static readonly string[] _skipDevicePrefixes = new[] { "ram", "loop", "dm-" };
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/LinuxSystemDiskMetricsTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/LinuxSystemDiskMetricsTests.cs
index 80ebc818894..82391a092c3 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/LinuxSystemDiskMetricsTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/Disk/LinuxSystemDiskMetricsTests.cs
@@ -11,13 +11,12 @@
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Time.Testing;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Disk.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public class LinuxSystemDiskMetricsTests
{
private static readonly string[] _skipDevicePrefixes = new[] { "ram", "loop", "dm-" };
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxCountersTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxCountersTests.cs
index 4f8dbf9547f..5ea771a9ed2 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxCountersTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxCountersTests.cs
@@ -15,6 +15,7 @@
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
+[PlatformSpecific(TestPlatforms.Linux)]
public class LinuxCountersTests
{
[Fact]
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkMetricsTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkMetricsTests.cs
index 40536a3245c..cc4c9d56fe0 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkMetricsTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkMetricsTests.cs
@@ -10,13 +10,12 @@
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test.Helpers;
using Microsoft.Extensions.Time.Testing;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public class LinuxNetworkMetricsTests
{
private readonly Mock _tcpStateInfoProvider = new();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkUtilizationParserTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkUtilizationParserTests.cs
index 53b980bb93c..82edf8b758b 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkUtilizationParserTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxNetworkUtilizationParserTests.cs
@@ -10,6 +10,7 @@
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
+[PlatformSpecific(TestPlatforms.Linux)]
public sealed class LinuxNetworkUtilizationParserTests
{
private const string VerifiedDataDirectory = "Verified";
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV1Tests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV1Tests.cs
index 3820ec254e0..7323ad72d1f 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV1Tests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV1Tests.cs
@@ -8,16 +8,15 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.Shared.Pools;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public sealed class LinuxUtilizationParserCgroupV1Tests
{
- [ConditionalTheory]
+ [Theory]
[InlineData("DFIJEUWGHFWGBWEFWOMDOWKSLA")]
[InlineData("")]
[InlineData("________________________Asdasdasdas dd")]
@@ -40,7 +39,7 @@ public void Parser_Throws_When_Data_Is_Invalid(string line)
Assert.Throws(() => parser.GetCgroupRequestCpuV2());
}
- [ConditionalFact]
+ [Fact]
public void Parser_Can_Read_Host_And_Cgroup_Available_Cpu_Count()
{
var parser = new LinuxUtilizationParserCgroupV1(new FileNamesOnlyFileSystem(TestResources.TestFilesLocation), new FakeUserHz(100));
@@ -51,7 +50,7 @@ public void Parser_Can_Read_Host_And_Cgroup_Available_Cpu_Count()
Assert.Equal(1.0, cgroupCpuCount);
}
- [ConditionalFact]
+ [Fact]
public void Parser_Provides_Total_Available_Memory_In_Bytes()
{
var fs = new FileNamesOnlyFileSystem(TestResources.TestFilesLocation);
@@ -62,7 +61,7 @@ public void Parser_Provides_Total_Available_Memory_In_Bytes()
Assert.Equal(16_233_760UL * 1024, totalMem);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("----------------------")]
[InlineData("@ @#dddada")]
[InlineData("1231234124124")]
@@ -93,7 +92,7 @@ public void When_Calling_GetMemoryUsageInBytes_Parser_Throws_When_MemoryStat_Doe
Assert.Contains("total_inactive_file", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("----------------------")]
[InlineData("@ @#dddada")]
[InlineData("_1231234124124")]
@@ -119,7 +118,7 @@ public void When_Calling_GetMemoryUsageInBytes_Parser_Throws_When_UsageInBytes_D
Assert.Contains("/sys/fs/cgroup/memory/memory.usage_in_bytes", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData(10, 1)]
[InlineData(23, 22)]
[InlineData(100000, 10000)]
@@ -138,7 +137,7 @@ public void When_Calling_GetMemoryUsageInBytes_Parser_Throws_When_Inactive_Memor
Assert.Contains("lesser than", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("Mem")]
[InlineData("MemTotal:")]
[InlineData("MemTotal: 120")]
@@ -164,7 +163,7 @@ public void When_Calling_GetHostAvailableMemory_Parser_Throws_When_MemInfo_Does_
Assert.Contains("/proc/meminfo", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("kB", 231, 236544)]
[InlineData("MB", 287, 300_941_312)]
[InlineData("GB", 372, 399_431_958_528)]
@@ -183,7 +182,7 @@ public void When_Calling_GetHostAvailableMemory_Parser_Correctly_Transforms_Supp
Assert.Equal(bytes, memory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("0-11", 12)]
[InlineData("0", 1)]
[InlineData("1000", 1)]
@@ -210,7 +209,7 @@ public void When_No_Cgroup_Cpu_Limits_Are_Not_Set_We_Get_Available_Cpus_From_Cpu
Assert.Equal(result, cpus);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("-11")]
[InlineData("0-")]
[InlineData("d-22")]
@@ -238,7 +237,7 @@ public void Parser_Throws_When_CpuSet_Has_Invalid_Content(string content)
Assert.Contains("/sys/fs/cgroup/cpuset/cpuset.cpus", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("-1", "18")]
[InlineData("18", "-1")]
[InlineData("18", "")]
@@ -259,7 +258,7 @@ public void When_Quota_And_Period_Are_Minus_One_It_Fallbacks_To_Cpuset(string qu
Assert.Contains("/sys/fs/cgroup/cpuset/cpuset.cpus", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("dd1d", "18")]
[InlineData("-18", "18")]
[InlineData("\r\r\r\r\r", "18")]
@@ -287,7 +286,7 @@ public void Parser_Throws_When_Cgroup_Cpu_Files_Contain_Invalid_Data(string quot
Assert.Contains("/sys/fs/cgroup/cpu/cpu.cfs_", r.Message);
}
- [ConditionalFact]
+ [Fact]
public void ReadingCpuUsage_Does_Not_Throw_For_Valid_Input()
{
var f = new HardcodedValueFileSystem(new Dictionary
@@ -301,7 +300,7 @@ public void ReadingCpuUsage_Does_Not_Throw_For_Valid_Input()
Assert.Null(r);
}
- [ConditionalFact]
+ [Fact]
public void ReadingTotalMemory_Does_Not_Throw_For_Valid_Input()
{
var f = new HardcodedValueFileSystem(new Dictionary
@@ -316,7 +315,7 @@ public void ReadingTotalMemory_Does_Not_Throw_For_Valid_Input()
Assert.Null(r);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("2569530367000")]
[InlineData(" 2569530 36700 245693 4860924 82283 0 4360 0dsa 0 0 asdasd @@@@")]
[InlineData("asdasd 2569530 36700 245693 4860924 82283 0 4360 0 0 0")]
@@ -337,7 +336,7 @@ public void ReadingCpuUsage_Does_Throws_For_Valid_Input(string content)
Assert.Contains("proc/stat", r.Message);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("-1")]
[InlineData("")]
public void Parser_Throws_When_Cgroup_Cpu_Shares_Files_Contain_Invalid_Data(string content)
@@ -354,7 +353,7 @@ public void Parser_Throws_When_Cgroup_Cpu_Shares_Files_Contain_Invalid_Data(stri
Assert.Contains("/sys/fs/cgroup/cpu/cpu.shares", r.Message);
}
- [ConditionalFact]
+ [Fact]
public async Task ThreadSafetyAsync()
{
var f1 = new HardcodedValueFileSystem(new Dictionary
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV2Tests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV2Tests.cs
index 8986ac6a8ac..6bc3e10fc85 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV2Tests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationParserCgroupV2Tests.cs
@@ -7,19 +7,18 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.Shared.Pools;
-using Microsoft.TestUtilities;
using Moq;
using VerifyXunit;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public sealed class LinuxUtilizationParserCgroupV2Tests
{
private const string VerifiedDataDirectory = "Verified";
- [ConditionalTheory]
+ [Theory]
[InlineData("DFIJEUWGHFWGBWEFWOMDOWKSLA")]
[InlineData("")]
[InlineData("________________________Asdasdasdas dd")]
@@ -43,7 +42,7 @@ public void Throws_When_Data_Is_Invalid(string line)
Assert.Throws(() => parser.GetCgroupPeriodsIntervalInMicroSecondsV2());
}
- [ConditionalFact]
+ [Fact]
public void Can_Read_Host_And_Cgroup_Available_Cpu_Count()
{
var parser = new LinuxUtilizationParserCgroupV2(new FileNamesOnlyFileSystem(TestResources.TestFilesLocation), new FakeUserHz(100));
@@ -54,7 +53,7 @@ public void Can_Read_Host_And_Cgroup_Available_Cpu_Count()
Assert.Equal(2.0, cgroupCpuCount);
}
- [ConditionalFact]
+ [Fact]
public void Provides_Total_Available_Memory_In_Bytes()
{
var fs = new FileNamesOnlyFileSystem(TestResources.TestFilesLocation);
@@ -65,7 +64,7 @@ public void Provides_Total_Available_Memory_In_Bytes()
Assert.Equal(16_233_760UL * 1024, totalMem);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("----------------------")]
[InlineData("@ @#dddada")]
[InlineData("1231234124124")]
@@ -95,7 +94,7 @@ public Task Throws_When_TotalInactiveFile_Is_Invalid(string content)
return Verifier.Verify(r).UseParameters(content).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("----------------------")]
[InlineData("@ @#dddada")]
[InlineData("_1231234124124")]
@@ -120,7 +119,7 @@ public Task Throws_When_UsageInBytes_Is_Invalid(string content)
return Verifier.Verify(r).UseParameters(content).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("max\n", 134_796_910_592ul)]
[InlineData("1000000\n", 1_000_000ul)]
public void Returns_Available_Memory_When_AvailableMemoryInBytes_Is_Valid(string content, ulong expectedResult)
@@ -137,7 +136,7 @@ public void Returns_Available_Memory_When_AvailableMemoryInBytes_Is_Valid(string
Assert.Equal(expectedResult, result);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("Suspicious12312312")]
[InlineData("string@")]
[InlineData("string12312")]
@@ -154,7 +153,7 @@ public Task Throws_When_AvailableMemoryInBytes_Doesnt_Contain_Just_A_Number(stri
return Verifier.Verify(r).UseParameters(content).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalFact]
+ [Fact]
public Task Throws_When_UsageInBytes_Doesnt_Contain_A_Number()
{
var regexPatternforSlices = @"\w+.slice";
@@ -169,7 +168,7 @@ public Task Throws_When_UsageInBytes_Doesnt_Contain_A_Number()
return Verifier.Verify(r).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalFact]
+ [Fact]
public void Returns_Memory_Usage_When_Memory_Usage_Is_Valid()
{
// When memory usage is a positive number
@@ -195,7 +194,7 @@ public void Returns_Memory_Usage_When_Memory_Usage_Is_Valid()
Assert.Equal(0, r);
}
- [ConditionalTheory]
+ [Theory]
[InlineData(104343, 1)]
[InlineData(23423, 22)]
[InlineData(10000, 100)]
@@ -213,7 +212,7 @@ public Task Throws_When_Inactive_Memory_Is_Bigger_Than_Total_Memory(int inactive
return Verifier.Verify(r).UseParameters(inactive, total).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("Mem")]
[InlineData("MemTotal:")]
[InlineData("MemTotal: 120")]
@@ -238,7 +237,7 @@ public Task Throws_When_MemInfo_Does_Not_Contain_TotalMemory(string totalMemory)
return Verifier.Verify(r).UseParameters(totalMemory).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("kB", 231, 236_544)]
[InlineData("MB", 287, 300_941_312)]
[InlineData("GB", 372, 399_431_958_528)]
@@ -256,7 +255,7 @@ public void Transforms_Supported_Units_To_Bytes(string unit, int value, ulong by
Assert.Equal(bytes, memory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("0-11", 12)]
[InlineData("0", 1)]
[InlineData("1000", 1)]
@@ -282,7 +281,7 @@ public void Gets_Available_Cpus_From_CpuSetCpus_When_Cpu_Limits_Not_Set(string c
Assert.Equal(result, cpus);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("0::/")]
[InlineData("0::/fakeslice")]
public void Gets_Available_Cpus_From_CpuSetCpusFromSlices_When_Cpu_Limits_Not_Set(string slicepath)
@@ -300,7 +299,7 @@ public void Gets_Available_Cpus_From_CpuSetCpusFromSlices_When_Cpu_Limits_Not_Se
Assert.Equal(2, cpus);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("2500", 64.0)]
[InlineData("10000", 256.0)]
public void Calculates_Cpu_Request_From_Cpu_WeightInSlices(string content, float result)
@@ -317,7 +316,7 @@ public void Calculates_Cpu_Request_From_Cpu_WeightInSlices(string content, float
Assert.Equal(result, r);
}
- [ConditionalFact]
+ [Fact]
public void Gets_Available_Cpus_From_CpuSetCpus_When_Cpu_Max_Set_To_Max_()
{
var f = new HardcodedValueFileSystem(new Dictionary
@@ -332,7 +331,7 @@ public void Gets_Available_Cpus_From_CpuSetCpus_When_Cpu_Max_Set_To_Max_()
Assert.Equal(3, cpus);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("-11")]
[InlineData("0-")]
[InlineData("d-22")]
@@ -358,7 +357,7 @@ public Task Throws_When_CpuSet_Has_Invalid_Content(string content)
return Verifier.Verify(r).UseParameters(content).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalFact]
+ [Fact]
public Task Fallsback_To_Cpuset_When_Quota_And_Period_Are_Minus_One_()
{
var f = new HardcodedValueFileSystem(new Dictionary
@@ -373,7 +372,7 @@ public Task Fallsback_To_Cpuset_When_Quota_And_Period_Are_Minus_One_()
return Verifier.Verify(r).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("dd1d", "18")]
[InlineData("-18", "18")]
[InlineData("\r\r\r\r\r", "18")]
@@ -398,7 +397,7 @@ public Task Throws_When_Cgroup_Cpu_Files_Contain_Invalid_Data(string quota, stri
return Verifier.Verify(r).UseParameters(quota, period).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalFact]
+ [Fact]
public void Reads_CpuUsage_When_Valid_Input()
{
var f = new HardcodedValueFileSystem(new Dictionary
@@ -412,7 +411,7 @@ public void Reads_CpuUsage_When_Valid_Input()
Assert.Equal(77_994_900_000_000, r);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("0::/", "usage_usec 222222\nnr_periods 50", "222222000", "50")]
[InlineData("0::/fakeslice", "usage_usec 222222\nnr_periods 75", "222222000", "75")]
public void Reads_CpuUsageFromSlices_When_Valid_Input(string slicepath, string content, string expectedUsage, string expectedPeriods)
@@ -433,7 +432,7 @@ public void Reads_CpuUsageFromSlices_When_Valid_Input(string slicepath, string c
Assert.Equal(expectedPeriods, periods.ToString());
}
- [ConditionalFact]
+ [Fact]
public void Reads_TotalMemory_When_Valid_Input()
{
var f = new HardcodedValueFileSystem(new Dictionary
@@ -448,7 +447,7 @@ public void Reads_TotalMemory_When_Valid_Input()
Assert.Null(r);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("2569530367000")]
[InlineData(" 2569530 36700 245693 4860924 82283 0 4360 0dsa")]
[InlineData("asdasd 2569530 36700 245693 4860924 82283 0 4360 0 0 0")]
@@ -468,7 +467,7 @@ public Task Throws_When_CpuUsage_Invalid(string content)
return Verifier.Verify(r).UseParameters(content).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("usage_", 12222)]
[InlineData("dasd", -1)]
[InlineData("@#dddada", 342322)]
@@ -485,7 +484,7 @@ public Task Throws_When_CpuAcctUsage_Has_Invalid_Content_Both_Parts(string conte
return Verifier.Verify(r).UseParameters(content, value).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData(-32131)]
[InlineData(-1)]
[InlineData(-15.323)]
@@ -502,7 +501,7 @@ public Task Throws_When_Usage_Usec_Has_Negative_Value(int value)
return Verifier.Verify(r).UseParameters(value).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("-1")]
[InlineData("dasrz3424")]
[InlineData("0")]
@@ -520,7 +519,7 @@ public Task Throws_When_Cgroup_Cpu_Weight_Files_Contain_Invalid_Data(string cont
return Verifier.Verify(r).UseParameters(content).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("2500", 64.0)]
[InlineData("10000", 256.0)]
public void Calculates_Cpu_Request_From_Cpu_Weight(string content, float result)
@@ -536,7 +535,7 @@ public void Calculates_Cpu_Request_From_Cpu_Weight(string content, float result)
Assert.Equal(result, r);
}
- [ConditionalTheory]
+ [Theory]
[InlineData("0::/", "filename", "/sys/fs/cgroup/filename")]
[InlineData("0::/filesystem.slice", "filename", "/sys/fs/cgroup/filesystem.slice/filename")]
[InlineData("0::/filesystem.slice/", "filename", "/sys/fs/cgroup/filesystem.slice/filename")]
@@ -553,7 +552,7 @@ public void Create_Path_From_Proc_Self_Cgroup(string content, string filename, s
Assert.Equal(result, r);
}
- [ConditionalFact]
+ [Fact]
public async Task Is_Thread_Safe_Async()
{
var f1 = new HardcodedValueFileSystem(new Dictionary
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
index c60ec5fa834..a4621463a61 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
@@ -11,20 +11,18 @@
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Time.Testing;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Moq;
using VerifyXunit;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public sealed class LinuxUtilizationProviderTests
{
private const string VerifiedDataDirectory = "Verified";
- [ConditionalFact]
- [CombinatorialData]
+ [Fact]
public void Provider_Registers_Instruments()
{
var meterName = Guid.NewGuid().ToString();
@@ -104,8 +102,7 @@ public void Provider_Registers_Instruments()
Assert.Equal(0.5, samples.Single(i => i.instrument.Name == ResourceUtilizationInstruments.ProcessMemoryUtilization).value);
}
- [ConditionalFact]
- [CombinatorialData]
+ [Fact]
public void Provider_Registers_Instruments_CgroupV2()
{
var meterName = Guid.NewGuid().ToString();
@@ -218,8 +215,7 @@ public void Provider_Creates_Meter_With_Correct_Name()
Assert.Equal(ResourceUtilizationInstruments.MeterName, meter.Name);
}
- [ConditionalFact]
- [CombinatorialData]
+ [Fact]
public void Provider_Registers_Instruments_CgroupV2_WithoutHostCpu()
{
var meterName = Guid.NewGuid().ToString();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/OSFileSystemTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/OSFileSystemTests.cs
index 9746d8395a5..ce3a82f3495 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/OSFileSystemTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/OSFileSystemTests.cs
@@ -6,15 +6,14 @@
using System.Linq;
using System.Text;
using Microsoft.Shared.Pools;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Linux.Test;
-[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux specific tests")]
+[PlatformSpecific(TestPlatforms.Linux)]
public sealed class OSFileSystemTests
{
- [ConditionalFact]
+ [Fact]
public void GetDirectoryNames_ReturnsDirectoryNames()
{
var fileSystem = new OSFileSystem();
@@ -24,7 +23,7 @@ public void GetDirectoryNames_ReturnsDirectoryNames()
Assert.Single(directoryNames);
}
- [ConditionalFact]
+ [Fact]
public void Reading_First_File_Line_Works()
{
const string Content = "Name: cat";
@@ -37,7 +36,7 @@ public void Reading_First_File_Line_Works()
Assert.Equal(Content, s);
}
- [ConditionalFact]
+ [Fact]
public void Reading_The_Whole_File_Works()
{
const string Content = "user 1399428\nsystem 1124053\n";
@@ -51,7 +50,7 @@ public void Reading_The_Whole_File_Works()
Assert.Equal(Content, s);
}
- [ConditionalTheory]
+ [Theory]
[InlineData(128)]
[InlineData(256)]
[InlineData(512)]
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests.csproj b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests.csproj
index ff2cd26412f..5ad6486db28 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests.csproj
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests.csproj
@@ -19,6 +19,9 @@
-
+
+
+
+
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringBuilderTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringBuilderTests.cs
index d2e3d5d8292..45e075dbef7 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringBuilderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringBuilderTests.cs
@@ -4,12 +4,11 @@
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test.Publishers;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test;
-[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
+[PlatformSpecific(~TestPlatforms.OSX)]
public sealed class ResourceMonitoringBuilderTests
{
[ConditionalFact(Skip = "Not supported on MacOs.")]
@@ -33,7 +32,7 @@ public void AddPublisher_CalledOnce_AddsSinglePublisherToServiceCollection()
Assert.IsAssignableFrom(publishersArray.First());
}
- [ConditionalFact]
+ [Fact]
public void AddPublisher_CalledMultipleTimes_AddsMultiplePublishersToServiceCollection()
{
using var provider = new ServiceCollection()
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringExtensionsTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringExtensionsTests.cs
index 875fbb67158..4531d5513be 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringExtensionsTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/ResourceMonitoringExtensionsTests.cs
@@ -11,15 +11,14 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Hosting.Testing;
using Microsoft.Extensions.Options;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test;
public sealed class ResourceMonitoringExtensionsTests
{
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void Throw_Null_When_Registration_Ingredients_Null()
{
var services = new ServiceCollection();
@@ -30,8 +29,8 @@ public void Throw_Null_When_Registration_Ingredients_Null()
Assert.Throws(() => services.AddResourceMonitoring((b) => b.ConfigureMonitor((Action)null!)));
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void AddsResourceMonitoringService_ToServicesCollection()
{
using var provider = new ServiceCollection()
@@ -51,8 +50,8 @@ public void AddsResourceMonitoringService_ToServicesCollection()
Assert.IsAssignableFrom(trackerService);
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void AddsResourceMonitoringService_ToServicesCollection_NoArgs()
{
using var provider = new ServiceCollection()
@@ -68,8 +67,8 @@ public void AddsResourceMonitoringService_ToServicesCollection_NoArgs()
Assert.IsAssignableFrom(trackerService);
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void AddsResourceMonitoringService_AsHostedService()
{
using var provider = new ServiceCollection()
@@ -90,8 +89,8 @@ public void AddsResourceMonitoringService_AsHostedService()
Assert.IsAssignableFrom(trackerService);
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void ConfigureResourceUtilization_InitializeTrackerProperly()
{
using var host = FakeHost.CreateBuilder()
@@ -117,8 +116,8 @@ public void ConfigureResourceUtilization_InitializeTrackerProperly()
Assert.NotNull(publisher);
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void ConfigureMonitor_GivenOptionsDelegate_InitializeTrackerWithOptionsProperly()
{
const int SamplingWindowValue = 3;
@@ -146,8 +145,8 @@ public void ConfigureMonitor_GivenOptionsDelegate_InitializeTrackerWithOptionsPr
Assert.Equal(TimeSpan.FromSeconds(CalculationPeriodValue), options!.Value.PublishingWindow);
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void ConfigureMonitor_GivenIConfigurationSection_InitializeTrackerWithOptionsProperly()
{
const int SamplingWindowValue = 3;
@@ -188,8 +187,8 @@ public void ConfigureMonitor_GivenIConfigurationSection_InitializeTrackerWithOpt
Assert.Equal(TimeSpan.FromSeconds(CalculationPeriod), options!.Value.PublishingWindow);
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void Registering_Resource_Utilization_Adds_Only_One_Object_Of_Type_ResourceUtilizationService_To_DI_Container()
{
using var host = FakeHost.CreateBuilder()
@@ -212,8 +211,8 @@ public void Registering_Resource_Utilization_Adds_Only_One_Object_Of_Type_Resour
Assert.Same(tracker as ResourceMonitorService, background as ResourceMonitorService);
}
- [OSSkipCondition(OperatingSystems.Linux | OperatingSystems.Windows, SkipReason = "For MacOs only.")]
- [ConditionalFact]
+ [PlatformSpecific(TestPlatforms.OSX)]
+ [Fact]
public void AddResourceMonitoringInternal_WhenMacOs_ReturnsSameServiceCollection()
{
var services = new ServiceCollection();
@@ -226,8 +225,8 @@ public void AddResourceMonitoringInternal_WhenMacOs_ReturnsSameServiceCollection
Assert.DoesNotContain(services, s => s.ServiceType == typeof(ISnapshotProvider));
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void AddResourceMonitoring_AddsISnapshotProvider()
{
var services = new ServiceCollection();
@@ -240,8 +239,8 @@ public void AddResourceMonitoring_AddsISnapshotProvider()
Assert.Contains(services, s => s.ServiceType == typeof(ISnapshotProvider));
}
- [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
- [ConditionalFact]
+ [PlatformSpecific(~TestPlatforms.OSX)]
+ [Fact]
public void AddResourceMonitoringInternal_CallsConfigureDelegate()
{
var services = new ServiceCollection();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoRatePerfCounterTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoRatePerfCounterTests.cs
index f2131afd3f5..85da127fca4 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoRatePerfCounterTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoRatePerfCounterTests.cs
@@ -5,19 +5,18 @@
using System.Runtime.Versioning;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
using Microsoft.Extensions.Time.Testing;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Disk.Test;
[SupportedOSPlatform("windows")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public class WindowsDiskIoRatePerfCounterTests
{
private const string CategoryName = "LogicalDisk";
- [ConditionalFact]
+ [Fact]
public void DiskReadsPerfCounter_Per60Seconds()
{
const string CounterName = WindowsDiskPerfCounterNames.DiskReadsCounter;
@@ -64,7 +63,7 @@ public void DiskReadsPerfCounter_Per60Seconds()
Assert.Equal(660, ratePerfCounters.TotalCountDict["D:"]); // 450 + 3.5 * 60 = 660
}
- [ConditionalFact]
+ [Fact]
public void DiskWriteBytesPerfCounter_Per30Seconds()
{
const string CounterName = WindowsDiskPerfCounterNames.DiskWriteBytesCounter;
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoTimePerfCounterTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoTimePerfCounterTests.cs
index 4daf808240b..86f91d96dbc 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoTimePerfCounterTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskIoTimePerfCounterTests.cs
@@ -5,19 +5,18 @@
using System.Runtime.Versioning;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
using Microsoft.Extensions.Time.Testing;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Disk.Test;
[SupportedOSPlatform("windows")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public class WindowsDiskIoTimePerfCounterTests
{
private const string CategoryName = "LogicalDisk";
- [ConditionalFact]
+ [Fact]
public void DiskReadsPerfCounter_Per60Seconds()
{
const string CounterName = WindowsDiskPerfCounterNames.DiskReadsCounter;
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskMetricsTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskMetricsTests.cs
index a592aacce19..563f800f4ae 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskMetricsTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Disk/WindowsDiskMetricsTests.cs
@@ -12,20 +12,19 @@
using Microsoft.Extensions.Logging.Testing;
using Microsoft.Extensions.Time.Testing;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Disk.Test;
[SupportedOSPlatform("windows")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public class WindowsDiskMetricsTests
{
private const string CategoryName = "LogicalDisk";
private readonly FakeLogger _fakeLogger = new();
- [ConditionalFact]
+ [Fact]
public void Creates_Meter_With_Correct_Name()
{
using var meterFactory = new TestMeterFactory();
@@ -43,7 +42,7 @@ public void Creates_Meter_With_Correct_Name()
Assert.Equal(ResourceUtilizationInstruments.MeterName, meter.Name);
}
- [ConditionalFact]
+ [Fact]
public void DiskOperationMetricsTest()
{
using var meterFactory = new TestMeterFactory();
@@ -117,7 +116,7 @@ public void DiskOperationMetricsTest()
Assert.Equal(5700, measurements.Last(x => x.MatchesTags(writeTag, deviceTagD)).Value); // 3600 + 35 * 60 = 5700
}
- [ConditionalFact]
+ [Fact]
public void DiskIoBytesMetricsTest()
{
using var meterFactory = new TestMeterFactory();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/MemoryInfoTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/MemoryInfoTests.cs
index ea20aad2d65..1f2e130589b 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/MemoryInfoTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/MemoryInfoTests.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Interop;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
@@ -12,10 +11,10 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
///
/// These tests are added for coverage reasons, but the code doesn't have
/// the necessary environment predictability to really test it.
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public sealed class MemoryInfoTests
{
- [ConditionalFact]
+ [Fact]
public void GetGlobalMemory()
{
var memoryStatus = new MemoryInfo().GetMemoryStatus();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterFactoryTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterFactoryTests.cs
index 768fd268175..ff0845ba099 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterFactoryTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterFactoryTests.cs
@@ -2,16 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Versioning;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
[SupportedOSPlatform("windows")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public class PerformanceCounterFactoryTests
{
- [ConditionalFact]
+ [Fact]
public void GetInstanceNameTest()
{
var performanceCounterFactory = new PerformanceCounterFactory();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterWrapperTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterWrapperTests.cs
index f27646ae327..30b6ab78449 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterWrapperTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/PerformanceCounterWrapperTests.cs
@@ -2,16 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.Versioning;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
[SupportedOSPlatform("windows")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public class PerformanceCounterWrapperTests
{
- [ConditionalFact]
+ [Fact]
public void GetInstanceNameTest()
{
var wrapper = new PerformanceCounterWrapper("Processor", "% Processor Time", "_Total");
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/ProcessInfoTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/ProcessInfoTests.cs
index ab83f2677df..96f75b6ba7f 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/ProcessInfoTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/ProcessInfoTests.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Interop;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/SystemInfoTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/SystemInfoTests.cs
index a0e9485bd00..740d14fc5f3 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/SystemInfoTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/SystemInfoTests.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Interop;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
@@ -12,13 +11,13 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
///
/// These tests are added for coverage reasons, but the code doesn't have
/// the necessary environment predictability to really test it.
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public sealed class SystemInfoTests
{
///
/// Get basic system info.
///
- [ConditionalFact]
+ [Fact]
public void GetSystemInfo()
{
var sysInfo = new SystemInfo().GetSystemInfo();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Tcp6TableInfoTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Tcp6TableInfoTests.cs
index a5dfdb5c170..584e73e178a 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Tcp6TableInfoTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/Tcp6TableInfoTests.cs
@@ -6,7 +6,6 @@
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Network;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
@@ -15,7 +14,7 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
/// Keep this Test to distinguish different tests for IPv6.
///
[Collection("Tcp Connection Tests")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public sealed class Tcp6TableInfoTests
{
public static readonly TimeSpan DefaultTimeSpan = TimeSpan.FromSeconds(5);
@@ -226,7 +225,7 @@ public static uint FakeGetTcp6TableWithFakeInformation(IntPtr pTcp6Table, ref ui
return (uint)NTSTATUS.Success;
}
- [ConditionalFact]
+ [Fact]
public void Test_Tcp6TableInfo_Get_UnsuccessfulStatus_All_The_Time()
{
var options = new ResourceMonitoringOptions
@@ -243,7 +242,7 @@ public void Test_Tcp6TableInfo_Get_UnsuccessfulStatus_All_The_Time()
});
}
- [ConditionalFact]
+ [Fact]
public void Test_Tcp6TableInfo_Get_InsufficientBuffer_Then_Get_InvalidParameter()
{
var options = new ResourceMonitoringOptions
@@ -259,7 +258,7 @@ public void Test_Tcp6TableInfo_Get_InsufficientBuffer_Then_Get_InvalidParameter(
});
}
- [ConditionalFact]
+ [Fact]
public void Test_Tcp6TableInfo_Get_Correct_Information()
{
StartTimestamp = DateTimeOffset.UtcNow;
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/TcpTableInfoTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/TcpTableInfoTests.cs
index 8c88fc123dd..49fd3551d7a 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/TcpTableInfoTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/TcpTableInfoTests.cs
@@ -6,13 +6,12 @@
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Network;
-using Microsoft.TestUtilities;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
[Collection("Tcp Connection Tests")]
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public sealed class TcpTableInfoTests
{
public static readonly TimeSpan DefaultTimeSpan = TimeSpan.FromSeconds(5);
@@ -169,7 +168,7 @@ public static unsafe uint FakeGetTcpTableWithFakeInformation(IntPtr pTcpTable, r
return (uint)NTSTATUS.Success;
}
- [ConditionalFact]
+ [Fact]
public void Test_TcpTableInfo_Get_UnsuccessfulStatus_All_The_Time()
{
var options = new ResourceMonitoringOptions
@@ -185,7 +184,7 @@ public void Test_TcpTableInfo_Get_UnsuccessfulStatus_All_The_Time()
});
}
- [ConditionalFact]
+ [Fact]
public void Test_TcpTableInfo_Get_InsufficientBuffer_Then_Get_InvalidParameter()
{
var options = new ResourceMonitoringOptions
@@ -201,7 +200,7 @@ public void Test_TcpTableInfo_Get_InsufficientBuffer_Then_Get_InvalidParameter()
});
}
- [ConditionalFact]
+ [Fact]
public void Test_TcpTableInfo_Get_Correct_Information()
{
StartTimestamp = DateTimeOffset.UtcNow;
@@ -262,7 +261,7 @@ public void Test_TcpTableInfo_Get_Correct_Information()
Assert.Equal(2, tcpStateInfo.DeleteTcbCount);
}
- [ConditionalFact]
+ [Fact]
public void Test_TcpTableInfo_CalculateCount_default_branch()
{
TcpStateInfo tcpStateInfo = new();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsContainerSnapshotProviderTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsContainerSnapshotProviderTests.cs
index 63a142fe254..c43443d128c 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsContainerSnapshotProviderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsContainerSnapshotProviderTests.cs
@@ -18,6 +18,7 @@
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
+[PlatformSpecific(TestPlatforms.Windows)]
public sealed class WindowsContainerSnapshotProviderTests
{
private const string VerifiedDataDirectory = "Verified";
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsNetworkMetricsTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsNetworkMetricsTests.cs
index bafb5816eb9..e78521615b9 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsNetworkMetricsTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsNetworkMetricsTests.cs
@@ -6,16 +6,15 @@
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Test.Helpers;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Network;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Moq;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public class WindowsNetworkMetricsTests
{
- [ConditionalFact]
+ [Fact]
public void Creates_Meter_With_Correct_Name()
{
using var meterFactory = new TestMeterFactory();
diff --git a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsSnapshotProviderTests.cs b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsSnapshotProviderTests.cs
index 32cf5117aac..cc2701caea0 100644
--- a/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsSnapshotProviderTests.cs
+++ b/test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsSnapshotProviderTests.cs
@@ -12,14 +12,13 @@
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Time.Testing;
using Microsoft.Shared.Instruments;
-using Microsoft.TestUtilities;
using Moq;
using VerifyXunit;
using Xunit;
namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Windows.Test;
-[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows specific.")]
+[PlatformSpecific(TestPlatforms.Windows)]
public sealed class WindowsSnapshotProviderTests
{
private const string VerifiedDataDirectory = "Verified";
@@ -39,7 +38,7 @@ public WindowsSnapshotProviderTests()
_fakeLogger = new FakeLogger();
}
- [ConditionalFact]
+ [Fact]
public void BasicConstructor()
{
var provider = new WindowsSnapshotProvider(_fakeLogger, _meterFactoryMock.Object, _options);
@@ -51,7 +50,7 @@ public void BasicConstructor()
Assert.Equal(memoryStatus.TotalPhys, provider.Resources.MaximumMemoryInBytes);
}
- [ConditionalFact]
+ [Fact]
public void GetSnapshot_DoesNotThrowExceptions()
{
var provider = new WindowsSnapshotProvider(_fakeLogger, _meterFactoryMock.Object, _options);
@@ -60,7 +59,7 @@ public void GetSnapshot_DoesNotThrowExceptions()
Assert.Null(exception);
}
- [ConditionalFact]
+ [Fact]
public Task SnapshotProvider_EmitsLogRecord()
{
var provider = new WindowsSnapshotProvider(_fakeLogger, _meterFactoryMock.Object, _options);
@@ -71,7 +70,7 @@ public Task SnapshotProvider_EmitsLogRecord()
return Verifier.Verify(logRecords[0]).UseDirectory(VerifiedDataDirectory);
}
- [ConditionalTheory]
+ [Theory]
[CombinatorialData]
public void SnapshotProvider_EmitsCpuMetrics(bool useZeroToOneRange)
{
@@ -112,7 +111,7 @@ public void SnapshotProvider_EmitsCpuMetrics(bool useZeroToOneRange)
Assert.Equal(0.05 * multiplier, metricCollector.LastMeasurement?.Value); // Still consuming 5% of the CPU
}
- [ConditionalTheory]
+ [Theory]
[CombinatorialData]
public void SnapshotProvider_EmitsMemoryMetrics(bool useZeroToOneRange)
{
@@ -162,7 +161,7 @@ public void SnapshotProvider_EmitsMemoryMetrics(bool useZeroToOneRange)
Assert.Equal(1 * multiplier, Math.Round(metricCollector.LastMeasurement.Value)); // Consuming 100% of the memory
}
- [ConditionalFact]
+ [Fact]
public void Provider_Returns_MemoryConsumption()
{
// This is a synthetic test to have full test coverage:
@@ -170,7 +169,7 @@ public void Provider_Returns_MemoryConsumption()
Assert.InRange(usage, 0, long.MaxValue);
}
- [ConditionalFact]
+ [Fact]
public void Provider_Creates_Meter_With_Correct_Name()
{
using var meterFactory = new TestMeterFactory();
diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/AIChatWebExecutionTests.cs b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/AIChatWebExecutionTests.cs
index 1f82e25f135..6216a9e56af 100644
--- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/AIChatWebExecutionTests.cs
+++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/AIChatWebExecutionTests.cs
@@ -4,8 +4,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Microsoft.Extensions.TestHelpers;
using Microsoft.Shared.ProjectTemplates.Tests;
-using Microsoft.TestUtilities;
using Xunit;
using Xunit.Abstractions;
@@ -95,8 +95,7 @@ public async Task CreateRestoreAndBuild_AspireProjectName()
/// environment variable AI_TEMPLATES_TEST_PROJECT_NAMES to "true" or "1"
/// to enable it.
///
- [ConditionalTheory]
- [EnvironmentVariableCondition("AI_TEMPLATES_TEST_PROJECT_NAMES", "true", "1")]
+ [ConditionalTheory(typeof(TestConditions), nameof(TestConditions.IsAITemplatesTestProjectNamesSet))]
[MemberData(nameof(GetAspireProjectNameVariants))]
public async Task CreateRestoreAndBuild_AspireProjectName_Variants(string provider, string projectName)
{
diff --git a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj
index bd83d4fa93e..d0a89a7a003 100644
--- a/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj
+++ b/test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Microsoft.Extensions.AI.Templates.Tests.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/test/Shared/Shared.Tests.csproj b/test/Shared/Shared.Tests.csproj
index 2764d5f5d5d..b47133341e6 100644
--- a/test/Shared/Shared.Tests.csproj
+++ b/test/Shared/Shared.Tests.csproj
@@ -21,6 +21,7 @@
+
diff --git a/test/Shared/TestHelpers/TestConditions.cs b/test/Shared/TestHelpers/TestConditions.cs
new file mode 100644
index 00000000000..a6774850b9f
--- /dev/null
+++ b/test/Shared/TestHelpers/TestConditions.cs
@@ -0,0 +1,31 @@
+// 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.Extensions.TestHelpers;
+
+///
+/// Provides static helper methods for conditional test execution with Microsoft.DotNet.XUnitExtensions.
+///
+public static class TestConditions
+{
+ ///
+ /// Checks if the specified environment variable has one of the specified values.
+ ///
+ /// The name of the environment variable.
+ /// The values to check against.
+ /// True if the environment variable matches one of the values; otherwise, false.
+ public static bool IsEnvironmentVariableSet(string variableName, params string[] values)
+ {
+ var currentValue = Environment.GetEnvironmentVariable(variableName);
+ return values.Any(value => string.Equals(value, currentValue, StringComparison.OrdinalIgnoreCase));
+ }
+
+ ///
+ /// Checks if AI_TEMPLATES_TEST_PROJECT_NAMES environment variable is set to "true" or "1".
+ ///
+ public static bool IsAITemplatesTestProjectNamesSet =>
+ IsEnvironmentVariableSet("AI_TEMPLATES_TEST_PROJECT_NAMES", "true", "1");
+}
diff --git a/test/TestUtilities/TestUtilities.csproj b/test/TestUtilities/TestUtilities.csproj
deleted file mode 100644
index d9e307f1e6d..00000000000
--- a/test/TestUtilities/TestUtilities.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- Microsoft.TestUtilities
- Microsoft.TestUtilities
- $(TestNetCoreTargetFrameworks)$(ConditionalNet462)
-
-
-
-
-
-
-
-
diff --git a/test/TestUtilities/XUnit/ConditionalFactAttribute.cs b/test/TestUtilities/XUnit/ConditionalFactAttribute.cs
deleted file mode 100644
index 92077e27dbc..00000000000
--- a/test/TestUtilities/XUnit/ConditionalFactAttribute.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System;
-using Xunit;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
-[XunitTestCaseDiscoverer("Microsoft.TestUtilities." + nameof(ConditionalFactDiscoverer), "Microsoft.TestUtilities")]
-public class ConditionalFactAttribute : FactAttribute
-{
-}
diff --git a/test/TestUtilities/XUnit/ConditionalFactDiscoverer.cs b/test/TestUtilities/XUnit/ConditionalFactDiscoverer.cs
deleted file mode 100644
index e007d95860a..00000000000
--- a/test/TestUtilities/XUnit/ConditionalFactDiscoverer.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-// Do not change this namespace without changing the usage in ConditionalFactAttribute
-namespace Microsoft.TestUtilities;
-
-internal sealed 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)
- : new SkippedFactTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(),
- discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); // Test case skippable at runtime.
- }
-}
diff --git a/test/TestUtilities/XUnit/ConditionalTheoryAttribute.cs b/test/TestUtilities/XUnit/ConditionalTheoryAttribute.cs
deleted file mode 100644
index d5f23068dd0..00000000000
--- a/test/TestUtilities/XUnit/ConditionalTheoryAttribute.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System;
-using Xunit;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
-[XunitTestCaseDiscoverer("Microsoft.TestUtilities." + nameof(ConditionalTheoryDiscoverer), "Microsoft.TestUtilities")]
-public class ConditionalTheoryAttribute : TheoryAttribute
-{
-}
diff --git a/test/TestUtilities/XUnit/ConditionalTheoryDiscoverer.cs b/test/TestUtilities/XUnit/ConditionalTheoryDiscoverer.cs
deleted file mode 100644
index e30b5206c8c..00000000000
--- a/test/TestUtilities/XUnit/ConditionalTheoryDiscoverer.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System.Collections.Generic;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-// Do not change this namespace without changing the usage in ConditionalTheoryAttribute
-namespace Microsoft.TestUtilities;
-
-internal sealed 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;
- }
- }
- }
-
- if (skipReason != null)
- {
- return base.CreateTestCasesForSkippedDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow, skipReason);
- }
-
- // Create test cases that can handle runtime SkipTestException
- return new[]
- {
- new SkippedTheoryTestCase(
- DiagnosticMessageSink,
- discoveryOptions.MethodDisplayOrDefault(),
- discoveryOptions.MethodDisplayOptionsOrDefault(),
- testMethod,
- 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),
- };
- }
-}
diff --git a/test/TestUtilities/XUnit/EnvironmentVariableConditionAttribute.cs b/test/TestUtilities/XUnit/EnvironmentVariableConditionAttribute.cs
deleted file mode 100644
index 45a54409047..00000000000
--- a/test/TestUtilities/XUnit/EnvironmentVariableConditionAttribute.cs
+++ /dev/null
@@ -1,86 +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.TestUtilities;
-
-///
-/// Skips a test based on the value of an environment variable.
-///
-[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
-public class EnvironmentVariableConditionAttribute : Attribute, ITestCondition
-{
- private string? _currentValue;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Name of the environment variable.
- /// Value(s) of the environment variable to match for the condition.
- ///
- /// By default, the test will be run if the value of the variable matches any of the supplied values.
- /// Set to False to run the test only if the value does not match.
- ///
- public EnvironmentVariableConditionAttribute(string variableName, params string[] values)
- {
- if (string.IsNullOrEmpty(variableName))
- {
- throw new ArgumentException("Value cannot be null or empty.", nameof(variableName));
- }
-
- if (values == null || values.Length == 0)
- {
- throw new ArgumentException("You must supply at least one value to match.", nameof(values));
- }
-
- VariableName = variableName;
- Values = values;
- }
-
- ///
- /// Gets or sets a value indicating whether the test should run if the value of the variable matches any
- /// of the supplied values. If False, the test runs only if the value does not match any of the
- /// supplied values. Default is True.
- ///
- public bool RunOnMatch { get; set; } = true;
-
- ///
- /// Gets the name of the environment variable.
- ///
- public string VariableName { get; }
-
- ///
- /// Gets the value(s) of the environment variable to match for the condition.
- ///
- public string[] Values { get; }
-
- ///
- /// Gets a value indicating whether the condition is met for the configured environment variable and values.
- ///
- public bool IsMet
- {
- get
- {
- _currentValue ??= Environment.GetEnvironmentVariable(VariableName);
- var hasMatched = Values.Any(value => string.Equals(value, _currentValue, StringComparison.OrdinalIgnoreCase));
-
- return RunOnMatch ? hasMatched : !hasMatched;
- }
- }
-
- ///
- /// Gets a value indicating the reason the test was skipped.
- ///
- public string SkipReason
- {
- get
- {
- var value = _currentValue ?? "(null)";
-
- return $"Test skipped on environment variable with name '{VariableName}' and value '{value}' " +
- $"for the '{nameof(RunOnMatch)}' value of '{RunOnMatch}'.";
- }
- }
-}
diff --git a/test/TestUtilities/XUnit/ITestCondition.cs b/test/TestUtilities/XUnit/ITestCondition.cs
deleted file mode 100644
index 347f3c69007..00000000000
--- a/test/TestUtilities/XUnit/ITestCondition.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-namespace Microsoft.TestUtilities;
-
-public interface ITestCondition
-{
- bool IsMet { get; }
-
- string SkipReason { get; }
-}
diff --git a/test/TestUtilities/XUnit/OSSkipConditionAttribute.cs b/test/TestUtilities/XUnit/OSSkipConditionAttribute.cs
deleted file mode 100644
index 586b53d3fcb..00000000000
--- a/test/TestUtilities/XUnit/OSSkipConditionAttribute.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System;
-#if NETCOREAPP || NET471_OR_GREATER
-using System.Runtime.InteropServices;
-#endif
-
-namespace Microsoft.TestUtilities;
-
-#pragma warning disable CA1019 // Define accessors for attribute arguments
-[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())
- {
- }
-
- // 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 executed 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.";
-
- private static OperatingSystems GetCurrentOS()
- {
-#if NETCOREAPP || NET471_OR_GREATER
- 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();
-#else
- // RuntimeInformation API is only available in .NET Framework 4.7.1+
- // .NET Framework 4.7 and below can only run on Windows.
- return OperatingSystems.Windows;
-#endif
- }
-}
-#pragma warning restore CA1019 // Define accessors for attribute arguments
diff --git a/test/TestUtilities/XUnit/OperatingSystems.cs b/test/TestUtilities/XUnit/OperatingSystems.cs
deleted file mode 100644
index 3bee3bac969..00000000000
--- a/test/TestUtilities/XUnit/OperatingSystems.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System;
-
-namespace Microsoft.TestUtilities;
-
-[Flags]
-public enum OperatingSystems
-{
- Linux = 1,
- MacOSX = 2,
- Windows = 4,
-}
diff --git a/test/TestUtilities/XUnit/SkipTestException.cs b/test/TestUtilities/XUnit/SkipTestException.cs
deleted file mode 100644
index 70f7d53c7d8..00000000000
--- a/test/TestUtilities/XUnit/SkipTestException.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System;
-
-namespace Microsoft.TestUtilities;
-
-public class SkipTestException : Exception
-{
- public SkipTestException(string reason)
- : base(reason)
- {
- }
-}
diff --git a/test/TestUtilities/XUnit/SkippedFactTestCase.cs b/test/TestUtilities/XUnit/SkippedFactTestCase.cs
deleted file mode 100644
index 79ace15ea6e..00000000000
--- a/test/TestUtilities/XUnit/SkippedFactTestCase.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.Threading;
-using System.Threading.Tasks;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-public class SkippedFactTestCase : XunitTestCase
-{
- [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes", error: true)]
- public SkippedFactTestCase()
- {
- }
-
- public SkippedFactTestCase(
- IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions,
- ITestMethod testMethod, object[]? testMethodArguments = null)
- : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
- {
- }
-
- public override async Task RunAsync(IMessageSink diagnosticMessageSink,
- IMessageBus messageBus,
- object[] constructorArguments,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource)
- {
- using SkippedTestMessageBus skipMessageBus = new(messageBus);
- var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource);
- if (skipMessageBus.SkippedTestCount > 0)
- {
- result.Failed -= skipMessageBus.SkippedTestCount;
- result.Skipped += skipMessageBus.SkippedTestCount;
- }
-
- return result;
- }
-}
diff --git a/test/TestUtilities/XUnit/SkippedTestCase.cs b/test/TestUtilities/XUnit/SkippedTestCase.cs
deleted file mode 100644
index 7b59125ffb8..00000000000
--- a/test/TestUtilities/XUnit/SkippedTestCase.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-#nullable disable
-
-using System;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-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()
- {
- }
-
- 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/test/TestUtilities/XUnit/SkippedTestMessageBus.cs b/test/TestUtilities/XUnit/SkippedTestMessageBus.cs
deleted file mode 100644
index 230586852b8..00000000000
--- a/test/TestUtilities/XUnit/SkippedTestMessageBus.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.Linq;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-/// Implements message bus to communicate tests skipped via SkipTestException.
-public sealed class SkippedTestMessageBus : IMessageBus
-{
- private readonly IMessageBus _innerBus;
-
- public SkippedTestMessageBus(IMessageBus innerBus)
- {
- _innerBus = innerBus;
- }
-
- public int SkippedTestCount { get; private set; }
-
- public void Dispose()
- {
- // nothing to dispose
- }
-
- public bool QueueMessage(IMessageSinkMessage message)
- {
- var testFailed = message as ITestFailed;
-
- if (testFailed != null)
- {
- var exceptionType = testFailed.ExceptionTypes.FirstOrDefault();
- if (exceptionType == typeof(SkipTestException).FullName)
- {
- SkippedTestCount++;
- return _innerBus.QueueMessage(new TestSkipped(testFailed.Test, testFailed.Messages.FirstOrDefault()));
- }
- }
-
- // Nothing we care about, send it on its way
- return _innerBus.QueueMessage(message);
- }
-}
diff --git a/test/TestUtilities/XUnit/SkippedTheoryTestCase.cs b/test/TestUtilities/XUnit/SkippedTheoryTestCase.cs
deleted file mode 100644
index e91a8f762d5..00000000000
--- a/test/TestUtilities/XUnit/SkippedTheoryTestCase.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;
-using System.Threading;
-using System.Threading.Tasks;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-///
-/// A test case for ConditionalTheory that can handle runtime SkipTestException
-/// by wrapping the message bus with SkippedTestMessageBus.
-///
-public class SkippedTheoryTestCase : XunitTestCase
-{
- [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes", error: true)]
- public SkippedTheoryTestCase()
- {
- }
-
- public SkippedTheoryTestCase(
- IMessageSink diagnosticMessageSink,
- TestMethodDisplay defaultMethodDisplay,
- TestMethodDisplayOptions defaultMethodDisplayOptions,
- ITestMethod testMethod,
- object[]? testMethodArguments = null)
- : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
- {
- }
-
- public override async Task RunAsync(IMessageSink diagnosticMessageSink,
- IMessageBus messageBus,
- object[] constructorArguments,
- ExceptionAggregator aggregator,
- CancellationTokenSource cancellationTokenSource)
- {
- using SkippedTestMessageBus skipMessageBus = new(messageBus);
- var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource);
- if (skipMessageBus.SkippedTestCount > 0)
- {
- result.Failed -= skipMessageBus.SkippedTestCount;
- result.Skipped += skipMessageBus.SkippedTestCount;
- }
-
- return result;
- }
-}
\ No newline at end of file
diff --git a/test/TestUtilities/XUnit/TestMethodExtensions.cs b/test/TestUtilities/XUnit/TestMethodExtensions.cs
deleted file mode 100644
index 88356330daf..00000000000
--- a/test/TestUtilities/XUnit/TestMethodExtensions.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.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System.Linq;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-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.OfType())
- {
- if (!condition.IsMet)
- {
- return condition.SkipReason;
- }
- }
-
- return null;
- }
-}
diff --git a/test/TestUtilities/XUnit/WORKAROUND_SkippedDataRowTestCase.cs b/test/TestUtilities/XUnit/WORKAROUND_SkippedDataRowTestCase.cs
deleted file mode 100644
index 123dba2fa48..00000000000
--- a/test/TestUtilities/XUnit/WORKAROUND_SkippedDataRowTestCase.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// Borrowed from https://github.com/dotnet/aspnetcore/blob/95ed45c67/src/Testing/src/xunit/
-
-using System;
-using System.ComponentModel;
-using Xunit.Abstractions;
-using Xunit.Sdk;
-
-namespace Microsoft.TestUtilities;
-
-// 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 sealed class WORKAROUND_SkippedDataRowTestCase : XunitTestCase
-{
- private 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)
- {
- _skipReason = skipReason;
- }
-
- ///
- public override void Deserialize(IXunitSerializationInfo data)
- {
- // SkipReason has to be read before we call base.Deserialize, this is the workaround.
- _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);
- }
-}