diff --git a/Directory.Packages.props b/Directory.Packages.props index 77687d45f7..2548b88d72 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,11 +21,10 @@ - + - - + diff --git a/test/AssemblyInfo.cs b/test/AssemblyInfo.cs index c7fc3b1f90..4647e4471c 100644 --- a/test/AssemblyInfo.cs +++ b/test/AssemblyInfo.cs @@ -1 +1,4 @@ -[assembly: CollectionBehavior(DisableTestParallelization = true)] +using ExRam.Gremlinq.Tests.Infrastructure; + +[assembly: CollectionBehavior(DisableTestParallelization = true)] +[assembly: TestFramework(typeof(GremlinqTestFramework))] diff --git a/test/Core.AspNet.Tests/ExRam.Gremlinq.Core.AspNet.Tests.csproj b/test/Core.AspNet.Tests/ExRam.Gremlinq.Core.AspNet.Tests.csproj index 707a54a833..f9170707ab 100644 --- a/test/Core.AspNet.Tests/ExRam.Gremlinq.Core.AspNet.Tests.csproj +++ b/test/Core.AspNet.Tests/ExRam.Gremlinq.Core.AspNet.Tests.csproj @@ -11,6 +11,7 @@ + diff --git a/test/Core.Tests/Assumptions.cs b/test/Core.Tests/Assumptions.cs index b736e493a5..37be526de8 100644 --- a/test/Core.Tests/Assumptions.cs +++ b/test/Core.Tests/Assumptions.cs @@ -11,7 +11,7 @@ public async Task SemaphoreSlim_WaitAsync_fails_upon_cancellation() var cts = new CancellationTokenSource(); var waitTask = semaphore.WaitAsync(cts.Token); - await Task.Delay(100); + await Task.Delay(100, TestContext.Current.CancellationToken); waitTask.IsCompleted .Should() diff --git a/test/Core.Tests/GremlinQueryExecutorTest.cs b/test/Core.Tests/GremlinQueryExecutorTest.cs index 1298089333..9c71294748 100644 --- a/test/Core.Tests/GremlinQueryExecutorTest.cs +++ b/test/Core.Tests/GremlinQueryExecutorTest.cs @@ -24,7 +24,7 @@ public void Invalid() GremlinQueryExecutor.Invalid .Execute(GremlinQueryExecutionContext.Create(_query)) .Awaiting(ex => ex - .ToArrayAsync()) + .ToArrayAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); } @@ -34,7 +34,7 @@ public async Task Empty() { var results = await GremlinQueryExecutor.Empty .Execute(GremlinQueryExecutionContext.Create(_query)) - .ToArrayAsync(); + .ToArrayAsync(TestContext.Current.CancellationToken); results .Should() @@ -55,7 +55,7 @@ public async Task RetryWithExponentialBackoff() await Verify(baseExecutor .RetryWithExponentialBackoff((_, ex) => true) .Execute(GremlinQueryExecutionContext.Create(_query)) - .ToArrayAsync()); + .ToArrayAsync(TestContext.Current.CancellationToken)); } [Fact] @@ -79,7 +79,7 @@ await baseExecutor }) .Execute(GremlinQueryExecutionContext.Create(_query)) .Awaiting(x => x - .ToArrayAsync()) + .ToArrayAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync() .WithInnerException(); @@ -114,7 +114,7 @@ async IAsyncEnumerable Core() .Be(0); yield return 42; - await Task.Delay(TimeSpan.FromMilliseconds(random.Next(5))); + await Task.Delay(TimeSpan.FromMilliseconds(random.Next(5)), TestContext.Current.CancellationToken); Interlocked.CompareExchange(ref state, 0, 1) .Should() diff --git a/test/Core.Tests/Serialization/OuterProjectionTest.cs b/test/Core.Tests/Serialization/OuterProjectionTest.cs index 734a777fd5..24a3e0d716 100644 --- a/test/Core.Tests/Serialization/OuterProjectionTest.cs +++ b/test/Core.Tests/Serialization/OuterProjectionTest.cs @@ -1,8 +1,6 @@ using System.Runtime.CompilerServices; using ExRam.Gremlinq.Tests.Infrastructure; -using Xunit.Abstractions; - namespace ExRam.Gremlinq.Core.Tests { public class OuterProjectionTest : QueryExecutionTest, IClassFixture @@ -16,7 +14,7 @@ public ProjectionVerifier([CallerFilePath] string sourceFile = "") : base(source public override Task Verify(IGremlinQueryBase query) => InnerVerify(query.ToTraversal().Projection.ToTraversal(query.AsAdmin().Environment).Steps.ToArray()); } - public OuterProjectionTest(GremlinqFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture, new ProjectionVerifier()) + public OuterProjectionTest(GremlinqFixture fixture) : base(fixture, new ProjectionVerifier()) { } } diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 21e510d66d..14f532fdd0 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -6,7 +6,7 @@ net6.0;net7.0;net8.0;$(TargetFrameworks) - + @@ -14,8 +14,8 @@ - - + + diff --git a/test/Providers.Core.Tests/PoolTests.cs b/test/Providers.Core.Tests/PoolTests.cs index edb6a4c5d7..e9b06825ca 100644 --- a/test/Providers.Core.Tests/PoolTests.cs +++ b/test/Providers.Core.Tests/PoolTests.cs @@ -34,7 +34,7 @@ public async Task Pool_creates_subClient() await poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .MoveNextAsync(); baseFactory @@ -55,13 +55,13 @@ public async Task Pool_creates_only_one_subClient_when_not_overlapping() await poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .MoveNextAsync(); await poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .MoveNextAsync(); baseFactory @@ -93,14 +93,14 @@ public async Task Pool_creates_second_client_when_overlapping() poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .MoveNextAsync() .AsTask(); poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .MoveNextAsync() .AsTask(); @@ -135,7 +135,7 @@ public async Task Pool_creates_not_more_clients_than_there_are_slots() poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .MoveNextAsync() .AsTask(); } @@ -169,7 +169,7 @@ public async Task Exception_is_forwarded() await poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .Awaiting(__ => __ .MoveNextAsync()) .Should() @@ -202,7 +202,7 @@ public async Task Client_is_recreated() poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .Awaiting(__ => __ .MoveNextAsync()) .Should() @@ -239,7 +239,7 @@ public async Task Retry_once_upon_ObjectDisposedException() var result = await System.Linq.AsyncEnumerable .ToArrayAsync(poolClient - .SubmitAsync(RequestMessage.Build("op").Create())); + .SubmitAsync(RequestMessage.Build("op").Create()), TestContext.Current.CancellationToken); baseFactory .Received(2) @@ -275,7 +275,7 @@ public async Task Retry_only_once_upon_ObjectDisposedException() poolClient .SubmitAsync(RequestMessage.Build("op").Create()) .AsAsyncEnumerable() - .GetAsyncEnumerator() + .GetAsyncEnumerator(TestContext.Current.CancellationToken) .Awaiting(__ => __ .MoveNextAsync()) .Should() diff --git a/test/Providers.CosmosDb.Tests/NoPasswordIntegrationTests.cs b/test/Providers.CosmosDb.Tests/NoPasswordIntegrationTests.cs index b6ac0193c1..7b4f791485 100644 --- a/test/Providers.CosmosDb.Tests/NoPasswordIntegrationTests.cs +++ b/test/Providers.CosmosDb.Tests/NoPasswordIntegrationTests.cs @@ -39,7 +39,7 @@ public async Task No_password_bubbles_up() { await _g .Inject(42) - .ToArrayAsync() + .ToArrayAsync(TestContext.Current.CancellationToken) .Awaiting(_ => _) .Should() .ThrowAsync() diff --git a/test/Providers.GremlinServer.Tests/IntegrationTests.cs b/test/Providers.GremlinServer.Tests/IntegrationTests.cs index 1111d32499..85b7da0345 100644 --- a/test/Providers.GremlinServer.Tests/IntegrationTests.cs +++ b/test/Providers.GremlinServer.Tests/IntegrationTests.cs @@ -28,7 +28,7 @@ public IntegrationTests(GremlinServerContainerFixture fixture) : base( [Fact] public async Task FirstAsync() => (await _g .Inject(42) - .FirstAsync()) + .FirstAsync(TestContext.Current.CancellationToken)) .Should() .Be(42); @@ -37,14 +37,14 @@ public async Task FirstAsync_empty() => await _g .Inject(42) .None() .Awaiting(_ => _ - .FirstAsync()) + .FirstAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); [Fact] public async Task FirstOrDefaultAsync() => (await _g .Inject(42) - .FirstOrDefaultAsync()) + .FirstOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .Be(42); @@ -52,14 +52,14 @@ public async Task FirstOrDefaultAsync() => (await _g public async Task FirstOrDefaultAsync_empty() => (await _g .Inject(42) .None() - .FirstOrDefaultAsync()) + .FirstOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .Be(0); [Fact] public async Task SingleAsync() => (await _g .Inject(42) - .SingleAsync()) + .SingleAsync(TestContext.Current.CancellationToken)) .Should() .Be(42); @@ -68,7 +68,7 @@ public async Task SingleAsync_empty() => await _g .Inject(42) .None() .Awaiting(_ => _ - .SingleAsync()) + .SingleAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); @@ -76,14 +76,14 @@ public async Task SingleAsync_empty() => await _g public async Task SingleAsync_two_elements() => await _g .Inject(42, 43) .Awaiting(_ => _ - .SingleAsync()) + .SingleAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); [Fact] public async Task SingleOrDefaultAsync() => (await _g .Inject(42) - .SingleOrDefaultAsync()) + .SingleOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .Be(42); @@ -91,7 +91,7 @@ public async Task SingleOrDefaultAsync() => (await _g public async Task SingleOrDefaultAsync_empty() => (await _g .Inject(42) .None() - .SingleOrDefaultAsync()) + .SingleOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .Be(0); @@ -99,14 +99,14 @@ public async Task SingleOrDefaultAsync_empty() => (await _g public async Task SingleOrDefaultAsync_two_elements() => await _g .Inject(42, 43) .Awaiting(_ => _ - .SingleOrDefaultAsync()) + .SingleOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); [Fact] public async Task LastAsync() => (await _g .Inject(42, 43) - .LastAsync()) + .LastAsync(TestContext.Current.CancellationToken)) .Should() .Be(43); @@ -115,14 +115,14 @@ public async Task LastAsync_empty() => await _g .Inject(42) .None() .Awaiting(_ => _ - .LastAsync()) + .LastAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); [Fact] public async Task LastOrDefaultAsync() => (await _g .Inject(42, 43) - .LastOrDefaultAsync()) + .LastOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .Be(43); @@ -130,7 +130,7 @@ public async Task LastOrDefaultAsync() => (await _g public async Task LastOrDefaultAsync_empty() => (await _g .Inject(42) .None() - .LastOrDefaultAsync()) + .LastOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .Be(0); @@ -217,7 +217,7 @@ public Task TimeSpan_from_malformed_string() => _g .Inject("abc") .Cast() .Awaiting(_ => _ - .FirstOrDefaultAsync()) + .FirstOrDefaultAsync(TestContext.Current.CancellationToken)) .Should() .ThrowAsync(); @@ -242,7 +242,7 @@ public async Task Deserialization_of_typed_results_is_only_called_once() })))) .Inject(42) .Cast() - .FirstAsync(); + .FirstAsync(TestContext.Current.CancellationToken); result? .ToArray() diff --git a/test/Providers.GremlinServer.Tests/WrongPasswordIntegrationTests.cs b/test/Providers.GremlinServer.Tests/WrongPasswordIntegrationTests.cs index b7433c6f23..011c0d675e 100644 --- a/test/Providers.GremlinServer.Tests/WrongPasswordIntegrationTests.cs +++ b/test/Providers.GremlinServer.Tests/WrongPasswordIntegrationTests.cs @@ -24,7 +24,7 @@ public async Task Wrong_password_bubbles_up() { await _g .Inject(42) - .ToArrayAsync() + .ToArrayAsync(TestContext.Current.CancellationToken) .Awaiting(_ => _) .Should() .ThrowAsync() diff --git a/test/Support.TestContainers.Tests/GremlinServerIntegrationTests.cs b/test/Support.TestContainers.Tests/GremlinServerIntegrationTests.cs index 161c7ba148..66c423f31e 100644 --- a/test/Support.TestContainers.Tests/GremlinServerIntegrationTests.cs +++ b/test/Support.TestContainers.Tests/GremlinServerIntegrationTests.cs @@ -35,6 +35,6 @@ public GremlinServerIntegrationTests() : base(new ExecutingVerifier()) public Task Inject_sum() => Verify(_g .Inject(1, 2, 3) .Sum() - .FirstAsync()); + .FirstAsync(TestContext.Current.CancellationToken)); } } diff --git a/test/Templates.Tests/ExRam.Gremlinq.Templates.Tests.csproj b/test/Templates.Tests/ExRam.Gremlinq.Templates.Tests.csproj index 529905a6da..42989ad5ae 100644 --- a/test/Templates.Tests/ExRam.Gremlinq.Templates.Tests.csproj +++ b/test/Templates.Tests/ExRam.Gremlinq.Templates.Tests.csproj @@ -9,6 +9,8 @@ + + diff --git a/test/Tests.Fixtures/CosmosDbEmulatorFixture.cs b/test/Tests.Fixtures/CosmosDbEmulatorFixture.cs index 7454726511..31571a991f 100644 --- a/test/Tests.Fixtures/CosmosDbEmulatorFixture.cs +++ b/test/Tests.Fixtures/CosmosDbEmulatorFixture.cs @@ -18,7 +18,7 @@ public class CosmosDbEmulatorFixture : GremlinqFixture private readonly string _collectionName = Guid.NewGuid().ToString("N"); private bool _containerCreated; - public override async Task InitializeAsync() + public override async ValueTask InitializeAsync() { await base.InitializeAsync(); @@ -38,7 +38,7 @@ await Policy } } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (_containerCreated) { @@ -52,6 +52,7 @@ await cosmosClient } await base.DisposeAsync(); + GC.SuppressFinalize(this); } protected override IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g diff --git a/test/Tests.Fixtures/TestContainerFixture.cs b/test/Tests.Fixtures/TestContainerFixture.cs index 8db7c71818..5cf8626c2f 100644 --- a/test/Tests.Fixtures/TestContainerFixture.cs +++ b/test/Tests.Fixtures/TestContainerFixture.cs @@ -28,7 +28,7 @@ protected sealed override IGremlinQuerySource TransformQuerySource(IGremlinQuery throw new InvalidOperationException(); } - public override async Task InitializeAsync() + public override async ValueTask InitializeAsync() { for(var i = 0; i < 42; i++) { @@ -65,7 +65,7 @@ await _container await base.InitializeAsync(); } - public override async Task DisposeAsync() + public override async ValueTask DisposeAsync() { if (_container is { } container) { @@ -83,6 +83,7 @@ public override async Task DisposeAsync() } await base.DisposeAsync(); + GC.SuppressFinalize(this); } protected abstract Task GetImage(); diff --git a/test/Tests.Infrastructure/GremlinqFixture.cs b/test/Tests.Infrastructure/GremlinqFixture.cs index a4f76d78bd..4cc9ffe3fc 100644 --- a/test/Tests.Infrastructure/GremlinqFixture.cs +++ b/test/Tests.Infrastructure/GremlinqFixture.cs @@ -13,7 +13,7 @@ public class GremlinqFixture : IAsyncLifetime protected virtual IGremlinQuerySource TransformQuerySource(IGremlinQuerySource g) => g; - public virtual async Task InitializeAsync() + public virtual async ValueTask InitializeAsync() { _g = TransformQuerySource(g .ConfigureEnvironment(env => env @@ -21,8 +21,9 @@ public virtual async Task InitializeAsync() .AddGraphSonBinarySupport())); } - public virtual async Task DisposeAsync() + public virtual async ValueTask DisposeAsync() { + GC.SuppressFinalize(this); } public virtual IGremlinQuerySource GetQuerySource() => _g ?? throw new InvalidOperationException(); diff --git a/test/Tests.Infrastructure/GremlinqTestBase.cs b/test/Tests.Infrastructure/GremlinqTestBase.cs index 37904dd387..fbece77db9 100644 --- a/test/Tests.Infrastructure/GremlinqTestBase.cs +++ b/test/Tests.Infrastructure/GremlinqTestBase.cs @@ -1,6 +1,6 @@ namespace ExRam.Gremlinq.Tests.Infrastructure { - [TestCaseOrderer("ExRam.Gremlinq.Tests.Infrastructure.SideEffectTestCaseOrderer", "ExRam.Gremlinq.Tests.Infrastructure")] + [TestCaseOrderer(typeof(SideEffectTestCaseOrderer))] public abstract class GremlinqTestBase { private static readonly AsyncLocal CurrentTestBase = new(); diff --git a/test/Tests.Infrastructure/GremlinqTestFramework.cs b/test/Tests.Infrastructure/GremlinqTestFramework.cs new file mode 100644 index 0000000000..c2f22d7472 --- /dev/null +++ b/test/Tests.Infrastructure/GremlinqTestFramework.cs @@ -0,0 +1,41 @@ +using System.Reflection; + +using Xunit.Sdk; +using Xunit.v3; + +[assembly: CollectionBehavior(DisableTestParallelization = true)] + +namespace ExRam.Gremlinq.Tests.Infrastructure +{ + public sealed class GremlinqTestFramework : XunitTestFramework + { + private sealed class GremlinqTestFrameworkExecutor : ITestFrameworkExecutor + { + private readonly ITestFrameworkExecutor _baseExecutor; + + public GremlinqTestFrameworkExecutor(ITestFrameworkExecutor baseExecutor) + { + _baseExecutor = baseExecutor; + } + + public ValueTask RunTestCases(IReadOnlyCollection testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions) => _baseExecutor.RunTestCases( + testCases + .Where(testCase => + { + if (testCase.Traits.TryGetValue("Category", out var categories) && categories.Contains("IntegrationTest")) + return testCase.Traits.TryGetValue("ValidPlatform", out var validPlatforms) && validPlatforms.Any(validPlatform => OperatingSystem.IsOSPlatform(validPlatform)); + + return true; + }) + .ToArray(), + executionMessageSink, + executionOptions); + } + + public override string TestFrameworkDisplayName => "hallo"; + + protected override ITestFrameworkDiscoverer CreateDiscoverer(Assembly assembly) => base.CreateDiscoverer(assembly); + + protected override ITestFrameworkExecutor CreateExecutor(Assembly assembly) => new GremlinqTestFrameworkExecutor(base.CreateExecutor(assembly)); + } +} diff --git a/test/Tests.Infrastructure/SideEffectTestCaseOrderer.cs b/test/Tests.Infrastructure/SideEffectTestCaseOrderer.cs index 369e27dd02..326b6b7694 100644 --- a/test/Tests.Infrastructure/SideEffectTestCaseOrderer.cs +++ b/test/Tests.Infrastructure/SideEffectTestCaseOrderer.cs @@ -1,5 +1,5 @@ -using Xunit.Abstractions; -using Xunit.Sdk; +using Xunit.Sdk; +using Xunit.v3; namespace ExRam.Gremlinq.Tests.Infrastructure { @@ -14,7 +14,7 @@ private TestCaseComparer() { } - public int Compare(TTestCase? x, TTestCase? y) => GetIndex(x!.TestMethod.Method.Name).CompareTo(GetIndex(y!.TestMethod.Method.Name)); + public int Compare(TTestCase? x, TTestCase? y) => GetIndex(x!.TestMethod!.MethodName).CompareTo(GetIndex(y!.TestMethod!.MethodName)); private static int GetIndex(string str) => str.StartsWith("Drop") ? 0 @@ -23,19 +23,9 @@ private static int GetIndex(string str) => str.StartsWith("Drop") : 2; } - public IEnumerable OrderTestCases(IEnumerable testCases) where TTestCase : ITestCase - { - return testCases - .Where(testCase => - { - if (testCase.Traits.TryGetValue("Category", out var categories) && categories.Contains("IntegrationTest")) - return testCase.Traits.TryGetValue("ValidPlatform", out var validPlatforms) && validPlatforms.Any(validPlatform => OperatingSystem.IsOSPlatform(validPlatform)); - - return true; - }) - .OrderBy(x => x, TestCaseComparer.Instance) - .ThenBy(x => x!.TestMethod.Method.Name, StringComparer.OrdinalIgnoreCase); - } - + public IReadOnlyCollection OrderTestCases(IReadOnlyCollection testCases) where TTestCase : notnull, ITestCase => testCases + .OrderBy(x => x, TestCaseComparer.Instance) + .ThenBy(x => x!.TestMethod!.MethodName, StringComparer.OrdinalIgnoreCase) + .ToArray(); } } diff --git a/test/Tests.Infrastructure/Traits/IntegrationTestAttribute.cs b/test/Tests.Infrastructure/Traits/IntegrationTestAttribute.cs index 3dfa5326ac..ec495240b8 100644 --- a/test/Tests.Infrastructure/Traits/IntegrationTestAttribute.cs +++ b/test/Tests.Infrastructure/Traits/IntegrationTestAttribute.cs @@ -1,8 +1,7 @@ -using Xunit.Sdk; +using Xunit.v3; namespace ExRam.Gremlinq.Tests.Infrastructure { - [TraitDiscoverer("ExRam.Gremlinq.Tests.Infrastructure.IntegrationTestDiscoverer", "ExRam.Gremlinq.Tests.Infrastructure")] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public sealed class IntegrationTestAttribute : Attribute, ITraitAttribute { @@ -12,6 +11,21 @@ public IntegrationTestAttribute(string validPlatform, bool canRunOnCI = false) ValidPlatform = validPlatform; } + public IReadOnlyCollection> GetTraits() + { + return [.. Core()]; + + IEnumerable> Core() + { + var isCi = bool.TryParse(Environment.GetEnvironmentVariable("CI"), out var ci) && ci; + + yield return new KeyValuePair("Category", "IntegrationTest"); + + if (CanRunOnCI || !isCi) + yield return new KeyValuePair("ValidPlatform", ValidPlatform); + } + } + public bool CanRunOnCI { get; } public string ValidPlatform { get; } } diff --git a/test/Tests.Infrastructure/Traits/IntegrationTestDiscoverer.cs b/test/Tests.Infrastructure/Traits/IntegrationTestDiscoverer.cs deleted file mode 100644 index b7464753da..0000000000 --- a/test/Tests.Infrastructure/Traits/IntegrationTestDiscoverer.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Xunit.Abstractions; -using Xunit.Sdk; - -namespace ExRam.Gremlinq.Tests.Infrastructure -{ - public class IntegrationTestDiscoverer : ITraitDiscoverer - { - public IEnumerable> GetTraits(IAttributeInfo traitAttribute) - { - var isCi = bool.TryParse(Environment.GetEnvironmentVariable("CI"), out var ci) && ci; - - yield return new KeyValuePair("Category", "IntegrationTest"); - - if (traitAttribute is ReflectionAttributeInfo { Attribute: IntegrationTestAttribute integrationTestAttribute }) - { - if (integrationTestAttribute.CanRunOnCI || !isCi) - yield return new KeyValuePair("ValidPlatform", integrationTestAttribute.ValidPlatform); - } - } - } -}