diff --git a/Directory.Packages.props b/Directory.Packages.props index 6625890b..dab148c9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -22,12 +22,8 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - + + + \ No newline at end of file diff --git a/tests/Doc/Bf_tutorial.cs b/tests/Doc/Bf_tutorial.cs index 5bdeb5e8..e2079434 100644 --- a/tests/Doc/Bf_tutorial.cs +++ b/tests/Doc/Bf_tutorial.cs @@ -22,7 +22,7 @@ public class BfTutorial // REMOVE_START public BfTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Bitmap_tutorial.cs b/tests/Doc/Bitmap_tutorial.cs index a2c0c1eb..a48178d5 100644 --- a/tests/Doc/Bitmap_tutorial.cs +++ b/tests/Doc/Bitmap_tutorial.cs @@ -21,7 +21,7 @@ public class BitmapTutorial // REMOVE_START public BitmapTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/CmdsHashExample.cs b/tests/Doc/CmdsHashExample.cs index ee1e86c9..111da1e3 100644 --- a/tests/Doc/CmdsHashExample.cs +++ b/tests/Doc/CmdsHashExample.cs @@ -19,7 +19,7 @@ public class CmdsHashExample // REMOVE_START public CmdsHashExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/CmdsListExample.cs b/tests/Doc/CmdsListExample.cs index 775e854a..8fb1dbcb 100644 --- a/tests/Doc/CmdsListExample.cs +++ b/tests/Doc/CmdsListExample.cs @@ -21,7 +21,7 @@ public class CmdsListExample // REMOVE_START public CmdsListExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/CmdsSetExample.cs b/tests/Doc/CmdsSetExample.cs index 3f1fc285..0ebb1c4c 100644 --- a/tests/Doc/CmdsSetExample.cs +++ b/tests/Doc/CmdsSetExample.cs @@ -15,7 +15,7 @@ public class CmdsSetExample // REMOVE_START public CmdsSetExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/CmdsSortedSetExamples.cs b/tests/Doc/CmdsSortedSetExamples.cs index cf3d56fa..6f05eaf5 100644 --- a/tests/Doc/CmdsSortedSetExamples.cs +++ b/tests/Doc/CmdsSortedSetExamples.cs @@ -21,7 +21,7 @@ public class CmdsSortedSet // REMOVE_START public CmdsSortedSet(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/CmdsStringExample.cs b/tests/Doc/CmdsStringExample.cs index 58361ddc..757e1e6b 100644 --- a/tests/Doc/CmdsStringExample.cs +++ b/tests/Doc/CmdsStringExample.cs @@ -21,7 +21,7 @@ public class CmdsStringExample // REMOVE_START public CmdsStringExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Cms_tutorial.cs b/tests/Doc/Cms_tutorial.cs index 05c4ba87..88f8e124 100644 --- a/tests/Doc/Cms_tutorial.cs +++ b/tests/Doc/Cms_tutorial.cs @@ -23,7 +23,7 @@ public class CmsTutorial // REMOVE_START public CmsTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Cuckoo_tutorial.cs b/tests/Doc/Cuckoo_tutorial.cs index 5d83d828..7168b82e 100644 --- a/tests/Doc/Cuckoo_tutorial.cs +++ b/tests/Doc/Cuckoo_tutorial.cs @@ -22,7 +22,7 @@ public class CuckooTutorial // REMOVE_START public CuckooTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Doc.csproj b/tests/Doc/Doc.csproj index 03a7dbd8..10311157 100644 --- a/tests/Doc/Doc.csproj +++ b/tests/Doc/Doc.csproj @@ -1,7 +1,8 @@ - net6.0;net7.0;net8.0;net481 + net8.0;net10.0;net481 false + Exe $(Nowarn);CS0612;CS0618 @@ -12,16 +13,11 @@ all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - diff --git a/tests/Doc/GeoIndexExample.cs b/tests/Doc/GeoIndexExample.cs index c4b94ff1..7add18a1 100644 --- a/tests/Doc/GeoIndexExample.cs +++ b/tests/Doc/GeoIndexExample.cs @@ -24,7 +24,7 @@ public class GeoIndexExample // REMOVE_START public GeoIndexExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void run() { diff --git a/tests/Doc/Geo_tutorial.cs b/tests/Doc/Geo_tutorial.cs index 95d293ec..c6b9aac9 100644 --- a/tests/Doc/Geo_tutorial.cs +++ b/tests/Doc/Geo_tutorial.cs @@ -21,7 +21,7 @@ public class GeoTutorial // REMOVE_START public GeoTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/HashExample.cs b/tests/Doc/HashExample.cs index 9ef2b10a..4361ab7e 100644 --- a/tests/Doc/HashExample.cs +++ b/tests/Doc/HashExample.cs @@ -17,7 +17,7 @@ public class HashExample // REMOVE_START public HashExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Hll_tutorial.cs b/tests/Doc/Hll_tutorial.cs index 84b2562f..b9155943 100644 --- a/tests/Doc/Hll_tutorial.cs +++ b/tests/Doc/Hll_tutorial.cs @@ -21,7 +21,7 @@ public class HllTutorial // REMOVE_START public HllTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/HomeJsonExample.cs b/tests/Doc/HomeJsonExample.cs index 1dd309ad..35377c66 100644 --- a/tests/Doc/HomeJsonExample.cs +++ b/tests/Doc/HomeJsonExample.cs @@ -24,7 +24,7 @@ public class HomeJsonExample // REMOVE_START public HomeJsonExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/HomeProbExample.cs b/tests/Doc/HomeProbExample.cs index 46bf2894..ac296af4 100644 --- a/tests/Doc/HomeProbExample.cs +++ b/tests/Doc/HomeProbExample.cs @@ -19,7 +19,7 @@ public class HomeProbExample // REMOVE_START public HomeProbExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Json_tutorial.cs b/tests/Doc/Json_tutorial.cs index 7d11cf0a..1ae8dc1a 100644 --- a/tests/Doc/Json_tutorial.cs +++ b/tests/Doc/Json_tutorial.cs @@ -23,7 +23,7 @@ public class JsonTutorial // REMOVE_START public JsonTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/ListTutorial.cs b/tests/Doc/ListTutorial.cs index aa1cd486..870d05ac 100644 --- a/tests/Doc/ListTutorial.cs +++ b/tests/Doc/ListTutorial.cs @@ -20,7 +20,7 @@ public class ListExample // REMOVE_START public ListExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/PipeTransExample.cs b/tests/Doc/PipeTransExample.cs index 87a13726..443aead8 100644 --- a/tests/Doc/PipeTransExample.cs +++ b/tests/Doc/PipeTransExample.cs @@ -16,7 +16,7 @@ public class PipeTransExample // REMOVE_START public PipeTransExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/QueryAggExample.cs b/tests/Doc/QueryAggExample.cs index d7d853eb..f00ce2e1 100644 --- a/tests/Doc/QueryAggExample.cs +++ b/tests/Doc/QueryAggExample.cs @@ -25,7 +25,7 @@ public class QueryAggExample // REMOVE_START public QueryAggExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/QueryEmExample.cs b/tests/Doc/QueryEmExample.cs index 54164b08..e5bb77ad 100644 --- a/tests/Doc/QueryEmExample.cs +++ b/tests/Doc/QueryEmExample.cs @@ -24,7 +24,7 @@ public class QueryEmExample // REMOVE_START public QueryEmExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/QueryFtExample.cs b/tests/Doc/QueryFtExample.cs index 73d6294c..bbbdcb69 100644 --- a/tests/Doc/QueryFtExample.cs +++ b/tests/Doc/QueryFtExample.cs @@ -24,7 +24,7 @@ public class QueryFtExample // REMOVE_START public QueryFtExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/QueryRangeExample.cs b/tests/Doc/QueryRangeExample.cs index c67a5170..9fa24dd3 100644 --- a/tests/Doc/QueryRangeExample.cs +++ b/tests/Doc/QueryRangeExample.cs @@ -24,7 +24,7 @@ public class QueryRangeExample // REMOVE_START public QueryRangeExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/SearchQuickstartExample.cs b/tests/Doc/SearchQuickstartExample.cs index 6cb31070..f8a8ab50 100644 --- a/tests/Doc/SearchQuickstartExample.cs +++ b/tests/Doc/SearchQuickstartExample.cs @@ -20,7 +20,7 @@ public class SearchQuickstartExample // REMOVE_START public SearchQuickstartExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/SetGetExample.cs b/tests/Doc/SetGetExample.cs index 4d8a2e31..0202ab04 100644 --- a/tests/Doc/SetGetExample.cs +++ b/tests/Doc/SetGetExample.cs @@ -17,7 +17,7 @@ public class SetGetExample // REMOVE_START public SetGetExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/SetsTutorial.cs b/tests/Doc/SetsTutorial.cs index 391c79bd..8eef262c 100644 --- a/tests/Doc/SetsTutorial.cs +++ b/tests/Doc/SetsTutorial.cs @@ -21,7 +21,7 @@ public class SetsExample // REMOVE_START public SetsExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/SortedSetExample.cs b/tests/Doc/SortedSetExample.cs index c271b24d..ce868d64 100644 --- a/tests/Doc/SortedSetExample.cs +++ b/tests/Doc/SortedSetExample.cs @@ -18,7 +18,7 @@ public class SortedSetExample // REMOVE_START public SortedSetExample(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/StreamTutorial.cs b/tests/Doc/StreamTutorial.cs index 59d93492..8589e703 100644 --- a/tests/Doc/StreamTutorial.cs +++ b/tests/Doc/StreamTutorial.cs @@ -21,7 +21,7 @@ public class StreamTutorial // REMOVE_START public StreamTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/StringSnippets.cs b/tests/Doc/StringSnippets.cs index cc7bb64e..70d74519 100644 --- a/tests/Doc/StringSnippets.cs +++ b/tests/Doc/StringSnippets.cs @@ -18,7 +18,7 @@ public class StringSnippets // REMOVE_START public StringSnippets(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Tdigest_tutorial.cs b/tests/Doc/Tdigest_tutorial.cs index 8d6b91ed..83409e23 100644 --- a/tests/Doc/Tdigest_tutorial.cs +++ b/tests/Doc/Tdigest_tutorial.cs @@ -22,7 +22,7 @@ public class TdigestTutorial // REMOVE_START public TdigestTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/TimeSeriesTutorial.cs b/tests/Doc/TimeSeriesTutorial.cs index be2b1adf..98581f30 100644 --- a/tests/Doc/TimeSeriesTutorial.cs +++ b/tests/Doc/TimeSeriesTutorial.cs @@ -27,7 +27,7 @@ public class TimeSeriesTutorial // REMOVE_START public TimeSeriesTutorial(EndpointsFixture fixture) : base(fixture) { } - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Topk_tutorial.cs b/tests/Doc/Topk_tutorial.cs index 33a9ec23..3de6653d 100644 --- a/tests/Doc/Topk_tutorial.cs +++ b/tests/Doc/Topk_tutorial.cs @@ -21,7 +21,7 @@ public class TopkTutorial { // REMOVE_START - [SkippableFact] + [Fact] // REMOVE_END public void Run() { diff --git a/tests/Doc/Usings.cs b/tests/Doc/Usings.cs index 69822964..185689fc 100644 --- a/tests/Doc/Usings.cs +++ b/tests/Doc/Usings.cs @@ -1,3 +1,2 @@ global using Xunit; -global using Xunit.Abstractions; - +global using FactAttribute = NRedisStack.Tests.FactAttribute; \ No newline at end of file diff --git a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs index 2e694da8..ffbd6341 100644 --- a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs +++ b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs @@ -3,7 +3,6 @@ using System.Runtime.CompilerServices; using StackExchange.Redis; using Xunit; -using Xunit.Abstractions; namespace NRedisStack.Tests; @@ -31,20 +30,20 @@ protected internal AbstractNRedisStackTest(EndpointsFixture endpointsFixture, IT this.log = log; } - protected ConnectionMultiplexer GetConnection(string endpointId = EndpointsFixture.Env.Standalone) => EndpointsFixture.GetConnectionById(this.DefaultConnectionConfig, endpointId); + protected ConnectionMultiplexer GetConnection(string endpointId = EndpointsFixture.Env.Standalone, bool shareConnection = true) => EndpointsFixture.GetConnectionById(this.DefaultConnectionConfig, endpointId, shareConnection); - protected ConnectionMultiplexer GetConnection(ConfigurationOptions configurationOptions, string endpointId = EndpointsFixture.Env.Standalone) => EndpointsFixture.GetConnectionById(configurationOptions, endpointId); + protected ConnectionMultiplexer GetConnection(ConfigurationOptions configurationOptions, string endpointId = EndpointsFixture.Env.Standalone) => EndpointsFixture.GetConnectionById(configurationOptions, endpointId, false); - protected IDatabase GetDatabase(string endpointId = EndpointsFixture.Env.Standalone) + protected IDatabase GetDatabase(string endpointId = EndpointsFixture.Env.Standalone, bool shareConnection = true) { - var redis = GetConnection(endpointId); + var redis = GetConnection(endpointId, shareConnection); IDatabase db = redis.GetDatabase(); return db; } - protected IDatabase GetCleanDatabase(string endpointId = EndpointsFixture.Env.Standalone) + protected IDatabase GetCleanDatabase(string endpointId = EndpointsFixture.Env.Standalone, bool shareConnection = true) { - var redis = GetConnection(endpointId); + var redis = GetConnection(endpointId, shareConnection); if (endpointId == EndpointsFixture.Env.Cluster) { @@ -65,7 +64,7 @@ protected IDatabase GetCleanDatabase(string endpointId = EndpointsFixture.Env.St protected void SkipIfTargetConnectionDoesNotExist(string id) { - Skip.IfNot(EndpointsFixture.IsTargetConnectionExist(id), $"The connection with id '{id}' is not configured."); + Assert.SkipUnless(EndpointsFixture.IsTargetConnectionExist(id), $"The connection with id '{id}' is not configured."); } private List keyNames = []; @@ -98,14 +97,14 @@ protected internal static List ReverseData(List Task.CompletedTask; + public ValueTask InitializeAsync() => default; public void Dispose() { //Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } - public Task DisposeAsync() => Task.CompletedTask; + public ValueTask DisposeAsync() => default; /*{ var redis = Redis.GetDatabase(); await redis.KeyDeleteAsync(keyNames.Select(i => (RedisKey)i).ToArray()); diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index 52e77df8..494ab9e9 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -1,3 +1,4 @@ +using System.ComponentModel; using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; @@ -12,7 +13,7 @@ public BloomTests(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestReserveBasic(string endpointId) { @@ -26,7 +27,7 @@ public void TestReserveBasic(string endpointId) Assert.False(bf.Exists(key, "item2")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestReserveBasicAsync(string endpointId) { @@ -40,7 +41,7 @@ public async Task TestReserveBasicAsync(string endpointId) Assert.False(await bf.ExistsAsync(key, "item2")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAddWhenExist(string endpointId) { @@ -51,7 +52,7 @@ public void TestAddWhenExist(string endpointId) Assert.False(bf.Add(key, "item1")); // second time } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddWhenExistAsync(string endpointId) { @@ -62,7 +63,7 @@ public async Task TestAddWhenExistAsync(string endpointId) Assert.False(await bf.AddAsync(key, "item1")); // second time } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAddExists(string endpointId) { @@ -73,7 +74,7 @@ public void TestAddExists(string endpointId) Assert.True(bf.Exists(key, "item1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddExistsAsync(string endpointId) { @@ -84,7 +85,7 @@ public async Task TestAddExistsAsync(string endpointId) Assert.True(await bf.ExistsAsync(key, "item1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAddExistsMulti(string endpointId) { @@ -100,7 +101,7 @@ public void TestAddExistsMulti(string endpointId) Assert.Equal(new[] { true, false, false }, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddExistsMultiAsync(string endpointId) { @@ -116,7 +117,7 @@ public async Task TestAddExistsMultiAsync(string endpointId) Assert.Equal(new[] { true, false, false }, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestExample(string endpointId) { @@ -145,7 +146,7 @@ public void TestExample(string endpointId) bf.Add("specialBloom", "foo"); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestExampleAsync(string endpointId) { @@ -174,7 +175,7 @@ public async Task TestExampleAsync(string endpointId) await bf.AddAsync("specialBloom", "foo"); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInsert(string endpointId) { @@ -190,7 +191,7 @@ public void TestInsert(string endpointId) Assert.True(bf.Exists("key", "item3")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInsertAsync(string endpointId) { @@ -206,7 +207,7 @@ public async Task TestInsertAsync(string endpointId) Assert.True(await bf.ExistsAsync("key", "item3")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestExistsNonExist(string endpointId) { @@ -217,7 +218,7 @@ public void TestExistsNonExist(string endpointId) Assert.False(bf.Exists("NonExistKey", item)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestExistsNonExistAsync(string endpointId) { @@ -228,7 +229,7 @@ public async Task TestExistsNonExistAsync(string endpointId) Assert.False(await bf.ExistsAsync("NonExistKey", item)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInfo(string endpointId) { @@ -244,7 +245,7 @@ public void TestInfo(string endpointId) Assert.Throws(() => bf.Info("notExistKey")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInfoAsync(string endpointId) { @@ -260,7 +261,7 @@ public async Task TestInfoAsync(string endpointId) await Assert.ThrowsAsync(() => bf.InfoAsync("notExistKey")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestScanDumpAndLoadChunk(string endpointId) { @@ -285,7 +286,7 @@ public void TestScanDumpAndLoadChunk(string endpointId) Assert.True(bf.Exists("bloom-load", "a")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestScanDumpAndLoadChunkAsync(string endpointId) { @@ -310,7 +311,7 @@ public async Task TestScanDumpAndLoadChunkAsync(string endpointId) Assert.True(await bf.ExistsAsync("bloom-load", "a")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestModulePrefixs(string endpointId) { @@ -324,7 +325,7 @@ public void TestModulePrefixs(string endpointId) Assert.NotEqual(bf1.GetHashCode(), bf2.GetHashCode()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCard(string endpointId) { @@ -343,7 +344,7 @@ public void TestCard(string endpointId) Assert.Throws(() => bf.Card("setKey")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCardAsync(string endpointId) { @@ -362,7 +363,7 @@ public async Task TestCardAsync(string endpointId) await Assert.ThrowsAsync(() => bf.CardAsync("setKey")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInsertArgsError(string endpointId) { diff --git a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs index 16b25369..f86491df 100644 --- a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs +++ b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs @@ -9,7 +9,7 @@ public class CmsTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTe private readonly string key = "CMS_TESTS"; - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInitByDim(string endpointId) { @@ -24,7 +24,7 @@ public void TestInitByDim(string endpointId) Assert.Equal(0, info.Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInitByDimAsync(string endpointId) { @@ -39,7 +39,7 @@ public async Task TestInitByDimAsync(string endpointId) Assert.Equal(0, info.Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInitByProb(string endpointId) { @@ -54,7 +54,7 @@ public void TestInitByProb(string endpointId) Assert.Equal(0, info.Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInitByProbAsync(string endpointId) { @@ -69,7 +69,7 @@ public async Task TestInitByProbAsync(string endpointId) Assert.Equal(0, info.Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestKeyAlreadyExists(string endpointId) { @@ -80,7 +80,7 @@ public void TestKeyAlreadyExists(string endpointId) Assert.Throws(() => cms.InitByDim("dup", 8, 6)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestKeyAlreadyExistsAsync(string endpointId) { @@ -91,7 +91,7 @@ public async Task TestKeyAlreadyExistsAsync(string endpointId) await Assert.ThrowsAsync(() => cms.InitByDimAsync("dup", 8, 6)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestIncrBy(string endpointId) { @@ -109,7 +109,7 @@ public void TestIncrBy(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestIncrByAsync(string endpointId) { @@ -127,7 +127,7 @@ public async Task TestIncrByAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestIncrByMultipleArgs(string endpointId) { @@ -150,7 +150,7 @@ public void TestIncrByMultipleArgs(string endpointId) Assert.Equal(25, info.Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestIncrByMultipleArgsAsync(string endpointId) { @@ -174,7 +174,7 @@ public async Task TestIncrByMultipleArgsAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestQuery(string endpointId) { @@ -192,7 +192,7 @@ public void TestQuery(string endpointId) Assert.Equal(new long[] { 10, 15 }, resp); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestQueryAsync(string endpointId) { @@ -308,7 +308,7 @@ public async Task TestMergeAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestModulePrefixs(string endpointId) { diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 7af86e67..b877514d 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -14,7 +14,7 @@ public CuckooTests(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestReserveBasic(string endpointId) { @@ -29,7 +29,7 @@ public void TestReserveBasic(string endpointId) Assert.False(cf.Exists(key, "item2")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestReserveBasicAsync(string endpointId) { @@ -43,7 +43,7 @@ public async Task TestReserveBasicAsync(string endpointId) Assert.False(await cf.ExistsAsync(key, "item2")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAddExists(string endpointId) { @@ -54,7 +54,7 @@ public void TestAddExists(string endpointId) Assert.True(cf.Exists(key, "item1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddExistsAsync(string endpointId) { @@ -65,7 +65,7 @@ public async Task TestAddExistsAsync(string endpointId) Assert.True(await cf.ExistsAsync(key, "item1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAddNX(string endpointId) { @@ -77,7 +77,7 @@ public void TestAddNX(string endpointId) Assert.True(cf.Exists(key, "item1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddNXAsync(string endpointId) { @@ -89,7 +89,7 @@ public async Task TestAddNXAsync(string endpointId) Assert.True(await cf.ExistsAsync(key, "item1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCountFilterDoesNotExist(string endpointId) { @@ -99,7 +99,7 @@ public void TestCountFilterDoesNotExist(string endpointId) Assert.Equal(0, cf.Count("notExistFilter", "notExistItem")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCountFilterDoesNotExistAsync(string endpointId) { @@ -109,7 +109,7 @@ public async Task TestCountFilterDoesNotExistAsync(string endpointId) Assert.Equal(0, await cf.CountAsync("notExistFilter", "notExistItem")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCountFilterExist(string endpointId) { @@ -120,7 +120,7 @@ public void TestCountFilterExist(string endpointId) Assert.Equal(0, cf.Count(key, "notExistItem")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCountFilterExistAsync(string endpointId) { @@ -131,7 +131,7 @@ public async Task TestCountFilterExistAsync(string endpointId) Assert.Equal(0, await cf.CountAsync(key, "notExistItem")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCountItemExist(string endpointId) { @@ -142,7 +142,7 @@ public void TestCountItemExist(string endpointId) Assert.Equal(1, cf.Count(key, "foo")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCountItemExistAsync(string endpointId) { @@ -153,7 +153,7 @@ public async Task TestCountItemExistAsync(string endpointId) Assert.Equal(1, await cf.CountAsync(key, "foo")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestDelete(string endpointId) { @@ -167,7 +167,7 @@ public void TestDelete(string endpointId) Assert.Throws(() => cf.Del("notExistKey", "item")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestDeleteAsync(string endpointId) { @@ -181,7 +181,7 @@ public async Task TestDeleteAsync(string endpointId) await Assert.ThrowsAsync(() => cf.DelAsync("notExistKey", "item")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInfo(string endpointId) { @@ -204,7 +204,7 @@ public void TestInfo(string endpointId) Assert.Throws(() => cf.Info("notExistKey")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInfoAsync(string endpointId) { @@ -229,7 +229,7 @@ public async Task TestInfoAsync(string endpointId) await Assert.ThrowsAsync(() => cf.InfoAsync("notExistKey")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInsert(string endpointId) { @@ -245,7 +245,7 @@ public void TestInsert(string endpointId) Assert.True(cf.Exists("key", "item3")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInsertAsync(string endpointId) { @@ -261,7 +261,7 @@ public async Task TestInsertAsync(string endpointId) Assert.True(await cf.ExistsAsync("key", "item3")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestInsertNX(string endpointId) { @@ -289,7 +289,7 @@ public void TestInsertNX(string endpointId) Assert.Throws(() => cf.InsertNX(key, [])); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestInsertNXAsync(string endpointId) { @@ -317,7 +317,7 @@ public async Task TestInsertNXAsync(string endpointId) await Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, [])); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestExistsNonExist(string endpointId) { @@ -328,7 +328,7 @@ public void TestExistsNonExist(string endpointId) Assert.False(cf.Exists("NonExistKey", item)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestExistsNonExistAsync(string endpointId) { @@ -339,7 +339,7 @@ public async Task TestExistsNonExistAsync(string endpointId) Assert.False(await cf.ExistsAsync("NonExistKey", item)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestScanDumpAndLoadChunk(string endpointId) { @@ -364,7 +364,7 @@ public void TestScanDumpAndLoadChunk(string endpointId) Assert.True(cf.Exists("cuckoo-load", "a")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestScanDumpAndLoadChunkAsync(string endpointId) { @@ -390,7 +390,7 @@ public async Task TestScanDumpAndLoadChunkAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestModulePrefixs(string endpointId) { diff --git a/tests/NRedisStack.Tests/EndpointsFixture.cs b/tests/NRedisStack.Tests/EndpointsFixture.cs index 0a1adf7c..8e57955d 100644 --- a/tests/NRedisStack.Tests/EndpointsFixture.cs +++ b/tests/NRedisStack.Tests/EndpointsFixture.cs @@ -1,3 +1,4 @@ +using System.Collections.Concurrent; using StackExchange.Redis; using System.Text.Json; using Xunit; @@ -85,13 +86,30 @@ public void Dispose() { } - public ConnectionMultiplexer GetConnectionById(ConfigurationOptions configurationOptions, string id) + public ConnectionMultiplexer GetConnectionById(ConfigurationOptions configurationOptions, string id, bool shareConnection) { - Skip.IfNot(redisEndpoints.ContainsKey(id), $"The connection with id '{id}' is not configured."); + Assert.SkipUnless(redisEndpoints.ContainsKey(id), $"The connection with id '{id}' is not configured."); - return redisEndpoints[id].CreateConnection(configurationOptions); + var protocol = TestContext.Current.GetRunProtocol(); + + if (!(shareConnection && shared.TryGetValue((id, protocol), out var connection))) + { + var options = configurationOptions.Clone(); // isolate before we start applying the protocol + options.Protocol = protocol.IsResp3() ? RedisProtocol.Resp3 : RedisProtocol.Resp2; + options.HighIntegrity = protocol.IsHighIntegrity(); + options.ConnectTimeout = 2000; + if (shareConnection) options.AbortOnConnectFail = false; + connection = redisEndpoints[id].CreateConnection(options); + if (shareConnection) shared[(id, protocol)] = connection; + } + + Assert.SkipUnless(connection.IsConnected, $"The connection with id '{id}' is not connected."); + return connection; } + // allow tests to share connections + ConcurrentDictionary<(string, RunProtocol), ConnectionMultiplexer> shared = new(); + public bool IsTargetConnectionExist(string id) { return redisEndpoints.ContainsKey(id); diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index a788aacd..ce6761b3 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -6,7 +6,6 @@ using NRedisStack.Search.Literals.Enums; using StackExchange.Redis; using Xunit; -using Xunit.Abstractions; using static NRedisStack.Search.Schema; namespace NRedisStack.Tests; @@ -18,7 +17,7 @@ public class ExampleTests(EndpointsFixture endpointsFixture, ITestOutputHelper t // private readonly string key = "EXAMPLES_TESTS"; - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void HSETandSearch(string endpointId) { @@ -70,7 +69,7 @@ public void HSETandSearch(string endpointId) Assert.Equal(0, lastNameRod.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task AsyncExample(string endpointId) { @@ -85,11 +84,11 @@ public async Task AsyncExample(string endpointId) var john = await json.GetAsync("key"); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void PipelineExample(string endpointId) { - Skip.If(true, "FIXME: JsonSet is not executed in pipeline, see https://github.com/redis/NRedisStack/issues/379"); + Assert.Skip("FIXME: JsonSet is not executed in pipeline, see https://github.com/redis/NRedisStack/issues/379"); // Pipeline can get IDatabase for pipeline IDatabase db = GetCleanDatabase(endpointId); @@ -122,7 +121,7 @@ public void PipelineExample(string endpointId) Assert.Equal(expected, result.ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public async Task JsonWithSearchPipeline(string endpointId) { @@ -270,7 +269,7 @@ public void TransactionExample(string endpointId) Assert.Equal("[1200]", totalAmtOfShachar.Result.ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestJsonConvert(string endpointId) { @@ -564,7 +563,7 @@ public void TestRedisCloudConnection_DotnetCore3() #endif #endif - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void BasicJsonExamplesTest(string endpointId) { @@ -819,7 +818,7 @@ public void BasicJsonExamplesTest(string endpointId) Assert.Equal("{\n\t\"arr1\":[\n\t\t\"val2\",\n\t\t\"val3\"\n\t]\n}", res.ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void AdvancedJsonExamplesTest(string endpointId) { @@ -965,7 +964,7 @@ public void AdvancedJsonExamplesTest(string endpointId) Assert.Equal(expected, res.ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void BasicQueryOperationsTest(string endpointId) { @@ -1138,7 +1137,7 @@ public void BasicQueryOperationsTest(string endpointId) Assert.Equal(expected, res[0].ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void AdvancedQueryOperationsTest(string endpointId) { diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 952d3359..d8f19c55 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -9,7 +9,7 @@ namespace NRedisStack.Tests; public class JsonTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestSetFromFile(string endpointId) { @@ -37,7 +37,7 @@ public void TestSetFromFile(string endpointId) Assert.Throws(() => commands.SetFromFile(keys[0], "$", "notExistingFile.json")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestSetFromDirectory(string endpointId) { @@ -90,7 +90,7 @@ public void TestSetFromDirectory(string endpointId) Directory.Delete("BaseDir", true); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestJsonSetNotExist(string endpointId) { @@ -104,7 +104,7 @@ public void TestJsonSetNotExist(string endpointId) Assert.True(commands.Set("Person:Shachar", "$", obj, When.Exists)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestJsonSetNotExistAsync(string endpointId) { @@ -132,7 +132,7 @@ public void TestModulePrefixs() Assert.NotEqual(json1.GetHashCode(), json2.GetHashCode()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestResp(string endpointId) { @@ -158,7 +158,7 @@ public void TestResp(string endpointId) conn.GetDatabase().KeyDelete(key); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestRespAsync(string endpointId) { @@ -184,7 +184,7 @@ public async Task TestRespAsync(string endpointId) conn.GetDatabase().KeyDelete(key); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestStringAppend(string endpointId) { @@ -212,7 +212,7 @@ public void TestStringAppend(string endpointId) Assert.Equal(6, simpleKeyResult[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestStringAppendAsync(string endpointId) { @@ -240,7 +240,7 @@ public async Task TestStringAppendAsync(string endpointId) Assert.Equal(6, simpleKeyResult[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void StringLength(string endpointId) { @@ -265,7 +265,7 @@ public void StringLength(string endpointId) Assert.Equal(3, simpleResult[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task StringLengthAsync(string endpointId) { @@ -290,7 +290,7 @@ public async Task StringLengthAsync(string endpointId) Assert.Equal(3, simpleResult[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Toggle(string endpointId) { @@ -312,7 +312,7 @@ public void Toggle(string endpointId) Assert.False(simpleResult[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ToggleAsync(string endpointId) { @@ -334,7 +334,7 @@ public async Task ToggleAsync(string endpointId) Assert.False(simpleResult[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Type(string endpointId) { @@ -358,7 +358,7 @@ public void Type(string endpointId) Assert.Equal(JsonType.BOOLEAN, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TypeAsync(string endpointId) { @@ -382,7 +382,7 @@ public async Task TypeAsync(string endpointId) Assert.Equal(JsonType.BOOLEAN, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ArrayAppend(string endpointId) { @@ -400,7 +400,7 @@ public void ArrayAppend(string endpointId) Assert.Equal(2, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ArrayAppendAsync(string endpointId) { @@ -418,7 +418,7 @@ public async Task ArrayAppendAsync(string endpointId) Assert.Equal(2, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ArrayIndex(string endpointId) { @@ -432,7 +432,7 @@ public void ArrayIndex(string endpointId) Assert.Equal(-1, res[1]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ArrayIndexAsync(string endpointId) { @@ -446,7 +446,7 @@ public async Task ArrayIndexAsync(string endpointId) Assert.Equal(-1, res[1]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ArrayInsert(string endpointId) { @@ -464,7 +464,7 @@ public void ArrayInsert(string endpointId) Assert.Equal(4, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ArrayInsertAsync(string endpointId) { @@ -482,7 +482,7 @@ public async Task ArrayInsertAsync(string endpointId) Assert.Equal(4, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ArrayLength(string endpointId) { @@ -499,7 +499,7 @@ public void ArrayLength(string endpointId) Assert.Equal(3, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ArrayLengthAsync(string endpointId) { @@ -516,7 +516,7 @@ public async Task ArrayLengthAsync(string endpointId) Assert.Equal(3, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ArrayPop(string endpointId) { @@ -535,7 +535,7 @@ public void ArrayPop(string endpointId) Assert.Equal("\"Ally\"", result[0].ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ArrayPopAsync(string endpointId) { @@ -554,7 +554,7 @@ public async Task ArrayPopAsync(string endpointId) Assert.Equal("\"Ally\"", result[0].ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ArrayTrim(string endpointId) { @@ -571,7 +571,7 @@ public void ArrayTrim(string endpointId) Assert.Equal(2, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ArrayTrimAsync(string endpointId) { @@ -588,7 +588,7 @@ public async Task ArrayTrimAsync(string endpointId) Assert.Equal(2, result[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Clear(string endpointId) { @@ -605,7 +605,7 @@ public void Clear(string endpointId) Assert.Equal(1, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ClearAsync(string endpointId) { @@ -622,7 +622,7 @@ public async Task ClearAsync(string endpointId) Assert.Equal(1, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Del(string endpointId) { @@ -639,7 +639,7 @@ public void Del(string endpointId) Assert.Equal(1, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task DelAsync(string endpointId) { @@ -656,7 +656,7 @@ public async Task DelAsync(string endpointId) Assert.Equal(1, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Forget(string endpointId) { @@ -673,7 +673,7 @@ public void Forget(string endpointId) Assert.Equal(1, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ForgetAsync(string endpointId) { @@ -690,7 +690,7 @@ public async Task ForgetAsync(string endpointId) Assert.Equal(1, result); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Get(string endpointId) { @@ -718,7 +718,7 @@ public void Get(string endpointId) Assert.Equal(35, people[1]!.Age); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task GetAsync(string endpointId) { @@ -867,7 +867,7 @@ public async Task MGetAsync(string endpointId) Assert.Equal("[\"world\"]", result[1].ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void NumIncrby(string endpointId) { @@ -881,7 +881,7 @@ public void NumIncrby(string endpointId) Assert.Null(result[2]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task NumIncrbyAsync(string endpointId) { @@ -895,7 +895,7 @@ public async Task NumIncrbyAsync(string endpointId) Assert.Null(result[2]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ObjectKeys(string endpointId) { @@ -914,7 +914,7 @@ public void ObjectKeys(string endpointId) Assert.Contains("b", result[1]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ObjectKeysAsync(string endpointId) { @@ -933,7 +933,7 @@ public async Task ObjectKeysAsync(string endpointId) Assert.Contains("b", result[1]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void ObjectLength(string endpointId) { @@ -950,7 +950,7 @@ public void ObjectLength(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task ObjectLengthAsync(string endpointId) { @@ -967,7 +967,7 @@ public async Task ObjectLengthAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestMultiPathGet(string endpointId) { @@ -992,7 +992,7 @@ public void TestMultiPathGet(string endpointId) Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world"); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestMultiPathGetAsync(string endpointId) { @@ -1017,7 +1017,7 @@ public async Task TestMultiPathGetAsync(string endpointId) Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world"); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Memory(string endpointId) { @@ -1032,7 +1032,7 @@ public void Memory(string endpointId) Assert.Equal(0, res); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task MemoryAsync(string endpointId) { @@ -1047,7 +1047,7 @@ public async Task MemoryAsync(string endpointId) Assert.Equal(0, res); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestSetFromFileAsync(string endpointId) { @@ -1075,7 +1075,7 @@ public async Task TestSetFromFileAsync(string endpointId) await Assert.ThrowsAsync(async () => await commands.SetFromFileAsync(keys[0], "$", "notExistingFile.json")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestSetFromDirectoryAsync(string endpointId) { @@ -1150,7 +1150,7 @@ public void TestJsonCommandBuilder() Assert.Equal("JSON.GET", getBuild2.Command); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestGetIssue198(string endpointId) { @@ -1168,7 +1168,7 @@ public void TestGetIssue198(string endpointId) Assert.Null(result2); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestGetIssue198_Async(string endpointId) { @@ -1186,7 +1186,7 @@ public async Task TestGetIssue198_Async(string endpointId) Assert.Null(result2); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestSetWithSerializationOptions(string endpointId) { @@ -1206,7 +1206,7 @@ public void TestSetWithSerializationOptions(string endpointId) Assert.Equal(person.Birthday, result.Birthday); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestSetWithSerializationOptionsAsync(string endpointId) { diff --git a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj index 66d5064c..b2e7380c 100644 --- a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj +++ b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj @@ -1,8 +1,9 @@ - net6.0;net8.0;net9.0;net10.0;net481 + net8.0;net9.0;net10.0;net481 false true + Exe @@ -26,17 +27,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - + - diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index b504f7fd..34134bf0 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -62,7 +62,7 @@ public void TestModulesPipeline(string endpointId) Assert.NotNull(db.TOPK().Info("topk-key")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] public void TestModulesPipelineWithoutGraph(string endpointId) @@ -110,7 +110,7 @@ public void TestModulesPipelineWithoutGraph(string endpointId) Assert.NotNull(db.TOPK().Info("topk-key")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestBloomPipeline(string endpointId) { @@ -136,7 +136,7 @@ public void TestBloomPipeline(string endpointId) } } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestJsonPipeline(string endpointId) { @@ -157,7 +157,7 @@ public void TestJsonPipeline(string endpointId) Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] public async Task Issue401_TestPipelineAsInitialCommand(string endpointId) diff --git a/tests/NRedisStack.Tests/RunProtocol.cs b/tests/NRedisStack.Tests/RunProtocol.cs new file mode 100644 index 00000000..6f369713 --- /dev/null +++ b/tests/NRedisStack.Tests/RunProtocol.cs @@ -0,0 +1,101 @@ +using Xunit.Internal; +using Xunit.Sdk; +using Xunit.v3; + +namespace NRedisStack.Tests; + +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] +public class RunPerProtocolAttribute(RunProtocol protocols = RunProtocol.Resp2 | RunProtocol.Resp3) : Attribute +{ + public RunProtocol Protocols => protocols; +} + +[Flags] +public enum RunProtocol +{ + None = 0, + Resp2 = 1 << 0, + Resp3 = 1 << 1, + // High integrity is not a separate protocol, but a flag that can be permuted with Resp2 and Resp3 + // This is niche, and is usually omitted. + Resp2HighIntegrity = 1 << 2, + Resp3HighIntegrity = 1 << 3, +} +public interface IRunProtocolTestCase +{ + RunProtocol Protocol { get; } +} + +public class ProtocolTestCase : XunitTestCase, IRunProtocolTestCase +{ + public RunProtocol Protocol { get; private set; } + + [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] + public ProtocolTestCase() { } + + public ProtocolTestCase(XunitTestCase testCase, RunProtocol protocol) : base( + testMethod: testCase.TestMethod, + testCaseDisplayName: $"{testCase.TestCaseDisplayName.Replace("NRedisStack.Tests.", "")} ({protocol.ToString()})", + uniqueID: testCase.UniqueID + protocol.ToString(), + @explicit: testCase.Explicit, + skipExceptions: testCase.SkipExceptions, + skipReason: testCase.SkipReason, + skipType: testCase.SkipType, + skipUnless: testCase.SkipUnless, + skipWhen: testCase.SkipWhen, + traits: testCase.TestMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase), + testMethodArguments: testCase.TestMethodArguments, + sourceFilePath: testCase.SourceFilePath, + sourceLineNumber: testCase.SourceLineNumber, + timeout: testCase.Timeout) + => Protocol = protocol; + + protected override void Serialize(IXunitSerializationInfo data) + { + base.Serialize(data); + data.AddValue("resp", (int)Protocol); + } + + protected override void Deserialize(IXunitSerializationInfo data) + { + base.Deserialize(data); + Protocol = (RunProtocol)data.GetValue("resp"); + } +} + +public class ProtocolDelayEnumeratedTestCase : XunitDelayEnumeratedTheoryTestCase, IRunProtocolTestCase +{ + public RunProtocol Protocol { get; private set; } + + [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] + public ProtocolDelayEnumeratedTestCase() { } + + public ProtocolDelayEnumeratedTestCase(XunitDelayEnumeratedTheoryTestCase testCase, RunProtocol protocol) : base( + testMethod: testCase.TestMethod, + testCaseDisplayName: $"{testCase.TestCaseDisplayName.Replace("NRedisStack.Tests.", "")} ({protocol.ToString()})", + uniqueID: testCase.UniqueID + protocol.ToString(), + @explicit: testCase.Explicit, + skipTestWithoutData: testCase.SkipTestWithoutData, + skipExceptions: testCase.SkipExceptions, + skipReason: testCase.SkipReason, + skipType: testCase.SkipType, + skipUnless: testCase.SkipUnless, + skipWhen: testCase.SkipWhen, + traits: testCase.TestMethod.Traits.ToReadWrite(StringComparer.OrdinalIgnoreCase), + sourceFilePath: testCase.SourceFilePath, + sourceLineNumber: testCase.SourceLineNumber, + timeout: testCase.Timeout) + => Protocol = protocol; + + protected override void Serialize(IXunitSerializationInfo data) + { + base.Serialize(data); + data.AddValue("resp", (int)Protocol); + } + + protected override void Deserialize(IXunitSerializationInfo data) + { + base.Deserialize(data); + Protocol = (RunProtocol)data.GetValue("resp"); + } +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Search/HybridSearchIntegrationTests.cs b/tests/NRedisStack.Tests/Search/HybridSearchIntegrationTests.cs index 10af82fe..77aa65ad 100644 --- a/tests/NRedisStack.Tests/Search/HybridSearchIntegrationTests.cs +++ b/tests/NRedisStack.Tests/Search/HybridSearchIntegrationTests.cs @@ -1,18 +1,16 @@ using System.Buffers; using System.Reflection; using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; using System.Text; using NRedisStack.RedisStackCommands; using NRedisStack.Search; using NRedisStack.Search.Aggregation; using StackExchange.Redis; using Xunit; -using Xunit.Abstractions; -using SkipException = Xunit.Sdk.SkipException; namespace NRedisStack.Tests.Search; +// [RunPerProtocol] public class HybridSearchIntegrationTests(EndpointsFixture endpointsFixture, ITestOutputHelper log) : AbstractNRedisStackTest(endpointsFixture, log), IDisposable { diff --git a/tests/NRedisStack.Tests/Search/HybridSearchUnitTests.cs b/tests/NRedisStack.Tests/Search/HybridSearchUnitTests.cs index 9f172c89..f131cfd3 100644 --- a/tests/NRedisStack.Tests/Search/HybridSearchUnitTests.cs +++ b/tests/NRedisStack.Tests/Search/HybridSearchUnitTests.cs @@ -4,7 +4,6 @@ using NRedisStack.Search.Aggregation; using StackExchange.Redis; using Xunit; -using Xunit.Abstractions; namespace NRedisStack.Tests.Search; diff --git a/tests/NRedisStack.Tests/Search/IndexCreationTests.cs b/tests/NRedisStack.Tests/Search/IndexCreationTests.cs index a9475b5a..22bc2f0f 100644 --- a/tests/NRedisStack.Tests/Search/IndexCreationTests.cs +++ b/tests/NRedisStack.Tests/Search/IndexCreationTests.cs @@ -4,10 +4,10 @@ using NRedisStack.RedisStackCommands; using Xunit; using NetTopologySuite.Geometries; -using Xunit.Abstractions; namespace NRedisStack.Tests.Search; +// [RunPerProtocol] public class IndexCreationTests(EndpointsFixture endpointsFixture, ITestOutputHelper log) : AbstractNRedisStackTest(endpointsFixture, log), IDisposable { diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index ca37c673..168e50b1 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -9,10 +9,10 @@ using System.Runtime.InteropServices; using NetTopologySuite.IO; using NetTopologySuite.Geometries; -using Xunit.Abstractions; namespace NRedisStack.Tests.Search; +// [RunPerProtocol] public class SearchTests(EndpointsFixture endpointsFixture, ITestOutputHelper log) : AbstractNRedisStackTest(endpointsFixture, log), IDisposable { @@ -24,12 +24,12 @@ private static void SkipClusterPre8(string endpointId) // Many of the FT.* commands are ... more awkward pre 8 when using cluster. Rather than // fight eventual-consistency/timing issues: grandfather the existing behaviour, and start // afresh from v8, where things behave much more predictably and reasonably. - Skip.If(endpointId == EndpointsFixture.Env.Cluster + Assert.SkipWhen(endpointId == EndpointsFixture.Env.Cluster && EndpointsFixture.RedisVersion.Major < 8, "Ignoring cluster tests for FT.SEARCH pre Redis 8.0"); // FIXME(imalinovskyi): We should skip cluster tests until https://github.com/RediSearch/RediSearch/pull/6960 // is released as part of Redis v8.2.x - Skip.If(endpointId == EndpointsFixture.Env.Cluster + Assert.SkipWhen(endpointId == EndpointsFixture.Env.Cluster && !EndpointsFixture.IsEnterprise && EndpointsFixture.RedisVersion.Minor < 4, "Ignoring cluster tests for FT.SEARCH pre Redis 8.4"); } @@ -145,7 +145,7 @@ public async Task TestAggregationRequestVerbatimAsync(string endpointId) Assert.Equal(0, res.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAggregationRequestTimeout(string endpointId) { @@ -168,7 +168,7 @@ public void TestAggregationRequestTimeout(string endpointId) Assert.Equal(2, res.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAggregationRequestTimeoutAsync(string endpointId) { @@ -191,7 +191,7 @@ public async Task TestAggregationRequestTimeoutAsync(string endpointId) Assert.Equal(2, res.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAggregations(string endpointId) { @@ -231,7 +231,7 @@ public void TestAggregations(string endpointId) Assert.Equal(10, r2.GetLong("sum")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAggregationsAsync(string endpointId) { @@ -272,7 +272,7 @@ public async Task TestAggregationsAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAggregationsLoad(string endpointId) { @@ -306,7 +306,7 @@ public void TestAggregationsLoad(string endpointId) Assert.Equal("world", res[0]!["t2"]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAggregationsLoadAsync(string endpointId) { @@ -340,7 +340,7 @@ public async Task TestAggregationsLoadAsync(string endpointId) Assert.Equal("world", res[0]!["t2"]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAggregationRequestParamsDialect(string endpointId) { @@ -372,7 +372,7 @@ public void TestAggregationRequestParamsDialect(string endpointId) Assert.Equal(10, r1.GetLong("sum")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAggregationRequestParamsDialectAsync(string endpointId) { @@ -405,7 +405,7 @@ public async Task TestAggregationRequestParamsDialectAsync(string endpointId) Assert.Equal(10, r1.GetLong("sum")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAggregationRequestParamsWithDefaultDialect(string endpointId) { @@ -437,7 +437,7 @@ public void TestAggregationRequestParamsWithDefaultDialect(string endpointId) Assert.Equal(10, r1.GetLong("sum")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAggregationRequestParamsWithDefaultDialectAsync(string endpointId) { @@ -477,7 +477,7 @@ public void TestDefaultDialectError() Assert.Throws(() => db.FT(0)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAlias(string endpointId) { @@ -498,7 +498,7 @@ public void TestAlias(string endpointId) } catch (RedisServerException rse) { - Skip.If(rse.Message.StartsWith("CROSSSLOT"), "legacy failure"); + Assert.SkipWhen(rse.Message.StartsWith("CROSSSLOT"), "legacy failure"); throw; } @@ -516,7 +516,7 @@ public void TestAlias(string endpointId) Assert.Throws(() => ft.AliasDel("ALIAS2")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAliasAsync(string endpointId) { @@ -537,7 +537,7 @@ public async Task TestAliasAsync(string endpointId) } catch (RedisServerException rse) { - Skip.If(rse.Message.StartsWith("CROSSSLOT"), "legacy failure"); + Assert.SkipWhen(rse.Message.StartsWith("CROSSSLOT"), "legacy failure"); throw; } @@ -555,7 +555,7 @@ public async Task TestAliasAsync(string endpointId) await Assert.ThrowsAsync(async () => await ft.AliasDelAsync("ALIAS2")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestApplyAndFilterAggregations(string endpointId) { @@ -602,7 +602,7 @@ public void TestApplyAndFilterAggregations(string endpointId) private static bool IsNear(double a, double b, double epsilon = 0.1) => Math.Abs(a - b) < epsilon; - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCreate(string endpointId) { @@ -636,7 +636,7 @@ public void TestCreate(string endpointId) Assert.Equal(0, res3.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCreateAsync(string endpointId) { @@ -665,7 +665,7 @@ public async Task TestCreateAsync(string endpointId) Assert.Equal(0, res3.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void CreateNoParams(string endpointId) { @@ -696,7 +696,7 @@ public void CreateNoParams(string endpointId) Assert.Equal(0, res3.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task CreateNoParamsAsync(string endpointId) { @@ -726,7 +726,7 @@ public async Task CreateNoParamsAsync(string endpointId) Assert.Equal(0, res3.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void CreateWithFieldNames(string endpointId) { @@ -771,7 +771,7 @@ public void FailWhenAttributeNotExist(string endpointId) RedisServerException exc = Assert.Throws(() => ft.Search(index, new("@first:Jo*"))); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task CreateWithFieldNamesAsync(string endpointId) { @@ -1295,7 +1295,7 @@ public async Task TestDialectConfigAsync(string endpointId) Assert.True(ft.ConfigSet("DEFAULT_DIALECT", "1")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCursor(string endpointId) { @@ -1351,7 +1351,7 @@ public async Task TestCursor(string endpointId) Assert.Contains("Cursor not found", ex.Message, StringComparison.OrdinalIgnoreCase); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCursorEnumerable(string endpointId) { @@ -1390,7 +1390,7 @@ public void TestCursorEnumerable(string endpointId) Assert.Equal(10, row.GetLong("sum")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCursorAsync(string endpointId) { @@ -1446,7 +1446,7 @@ public async Task TestCursorAsync(string endpointId) Assert.Contains("Cursor not found", ex.Message, StringComparison.OrdinalIgnoreCase); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCursorEnumerableAsync(string endpointId) { @@ -1615,7 +1615,7 @@ public void TestAggregationGroupBy(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestDictionary(string endpointId) { @@ -1636,7 +1636,7 @@ public void TestDictionary(string endpointId) Assert.Empty(ft.DictDump("dict")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestDropIndex(string endpointId) { @@ -1700,7 +1700,7 @@ private async Task DatabaseSizeAsync(IDatabase db) return checked((int)count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestDropIndexAsync(string endpointId) { @@ -1729,7 +1729,7 @@ public async Task TestDropIndexAsync(string endpointId) Assert.Contains("no such index", ex.Message, StringComparison.OrdinalIgnoreCase); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void dropIndexDD(string endpointId) { @@ -1757,7 +1757,7 @@ public void dropIndexDD(string endpointId) AssertDatabaseSize(db, 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task dropIndexDDAsync(string endpointId) { @@ -1785,7 +1785,7 @@ public async Task dropIndexDDAsync(string endpointId) AssertDatabaseSize(db, 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestDictionaryAsync(string endpointId) { @@ -1808,7 +1808,7 @@ public async Task TestDictionaryAsync(string endpointId) readonly string explainQuery = "@f3:f3_val @f2:f2_val @f1:f1_val"; - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestExplain(string endpointId) { @@ -1831,7 +1831,7 @@ public void TestExplain(string endpointId) Assert.False(res.Length == 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestExplainAsync(string endpointId) { @@ -1903,7 +1903,7 @@ public async Task TestExplainCliAsync(string endpointId) Assert.False(res.Length == 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestExplainWithDefaultDialect(string endpointId) { @@ -1921,7 +1921,7 @@ public void TestExplainWithDefaultDialect(string endpointId) Assert.False(res.Length == 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestExplainWithDefaultDialectAsync(string endpointId) { @@ -1939,7 +1939,7 @@ public async Task TestExplainWithDefaultDialectAsync(string endpointId) Assert.False(res.Length == 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestSynonym(string endpointId) { @@ -1966,7 +1966,7 @@ public void TestSynonym(string endpointId) Assert.Equal(expected, dump); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestSynonymAsync(string endpointId) { @@ -2006,7 +2006,7 @@ public void TestModulePrefixs() Assert.NotEqual(ft1.GetHashCode(), ft2.GetHashCode()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task GetTagFieldSyncAsync(string endpointId) { @@ -2065,7 +2065,7 @@ public async Task GetTagFieldSyncAsync(string endpointId) Assert.Equal("yellow", SyncRes[i++].ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync(string endpointId) { @@ -2199,7 +2199,7 @@ public void TestFTCreateParamsCommandBuilderNoStopwords() Assert.Equal("FT.CREATE", builedCommand.Command.ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestFilters(string endpointId) { @@ -2252,7 +2252,7 @@ public void TestFilters(string endpointId) Assert.Equal("doc1", res1.Documents[0].Id); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestFiltersAsync(string endpointId) { @@ -2521,7 +2521,7 @@ public void TestFieldsCommandBuilder() } } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestLimit(string endpointId) { @@ -2543,7 +2543,7 @@ public void TestLimit(string endpointId) Assert.Equal("a", res.GetResults()[0]["t1"].ToString()); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestLimitAsync(string endpointId) { @@ -2616,7 +2616,7 @@ public void TestVectorCount_Issue70() Assert.Equal(expected.Count(), actual.Args.Length); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void VectorSimilaritySearch(string endpointId) { @@ -2661,7 +2661,7 @@ public void VectorSimilaritySearch(string endpointId) Assert.Equal("{\"vector\":[2,2,2,2]}", jsonRes[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void QueryingVectorFields(string endpointId) { @@ -2710,7 +2710,7 @@ public async Task TestVectorFieldJson_Issue102Async() Assert.True(await ft.CreateAsync("my_index", new FTCreateParams().On(IndexDataType.JSON), schema)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestQueryAddParam_DefaultDialect(string endpointId) { @@ -2731,7 +2731,7 @@ public void TestQueryAddParam_DefaultDialect(string endpointId) Assert.Equal(2, res.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestQueryAddParam_DefaultDialectAsync(string endpointId) { @@ -2752,7 +2752,7 @@ public async Task TestQueryAddParam_DefaultDialectAsync(string endpointId) Assert.Equal(2, res.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestQueryParamsWithParams_DefaultDialect(string endpointId) { @@ -2782,7 +2782,7 @@ public void TestQueryParamsWithParams_DefaultDialect(string endpointId) Assert.Equal(2, res.TotalResults); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestBasicSpellCheck(string endpointId) { @@ -2804,7 +2804,7 @@ public void TestBasicSpellCheck(string endpointId) Assert.Equal(2, reply["name"]["name2"]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestBasicSpellCheckAsync(string endpointId) { @@ -2826,7 +2826,7 @@ public async Task TestBasicSpellCheckAsync(string endpointId) Assert.Equal(2, reply["name"]["name2"]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCrossTermDictionary(string endpointId) { @@ -2853,7 +2853,7 @@ public void TestCrossTermDictionary(string endpointId) .ExcludeTerm("slang"))); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCrossTermDictionaryAsync(string endpointId) { @@ -2925,7 +2925,7 @@ await Assert.ThrowsAsync(async () => await ft.SpellCheckAsync(index, "name", new FTSpellCheckParams().Dialect(0))); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestQueryParamsWithParams_DefaultDialectAsync(string endpointId) { @@ -2957,7 +2957,7 @@ public async Task TestQueryParamsWithParams_DefaultDialectAsync(string endpointI readonly string key = "SugTestKey"; - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAddAndGetSuggestion(string endpointId) { @@ -2981,7 +2981,7 @@ public void TestAddAndGetSuggestion(string endpointId) Assert.Single(ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddAndGetSuggestionAsync(string endpointId) { @@ -3005,7 +3005,7 @@ public async Task TestAddAndGetSuggestionAsync(string endpointId) Assert.Single(await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void AddSuggestionIncrAndGetSuggestionFuzzy(string endpointId) { @@ -3021,7 +3021,7 @@ public void AddSuggestionIncrAndGetSuggestionFuzzy(string endpointId) Assert.Equal(suggestion, ft.SugGet(key, suggestion.Substring(0, 3))[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task AddSuggestionIncrAndGetSuggestionFuzzyAsync(string endpointId) { @@ -3037,7 +3037,7 @@ public async Task AddSuggestionIncrAndGetSuggestionFuzzyAsync(string endpointId) Assert.Equal(suggestion, (await ft.SugGetAsync(key, suggestion.Substring(0, 3)))[0]); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void getSuggestionScores(string endpointId) { @@ -3059,7 +3059,7 @@ public void getSuggestionScores(string endpointId) } } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task getSuggestionScoresAsync(string endpointId) { @@ -3081,7 +3081,7 @@ public async Task getSuggestionScoresAsync(string endpointId) } } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void getSuggestionMax(string endpointId) { @@ -3097,7 +3097,7 @@ public void getSuggestionMax(string endpointId) Assert.Equal(2, ft.SugGetWithScores(key, "COU", true, max: 2).Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task getSuggestionMaxAsync(string endpointId) { @@ -3113,7 +3113,7 @@ public async Task getSuggestionMaxAsync(string endpointId) Assert.Equal(2, (await ft.SugGetWithScoresAsync(key, "COU", true, max: 2)).Count); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void getSuggestionNoHit(string endpointId) { @@ -3126,7 +3126,7 @@ public void getSuggestionNoHit(string endpointId) Assert.Empty(ft.SugGet(key, "DIF")); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task GetSuggestionNoHitAsync(string endpointId) { @@ -3139,7 +3139,7 @@ public async Task GetSuggestionNoHitAsync(string endpointId) Assert.Empty((await ft.SugGetAsync(key, "DIF"))); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void GetSuggestionLengthAndDeleteSuggestion(string endpointId) { @@ -3163,7 +3163,7 @@ public void GetSuggestionLengthAndDeleteSuggestion(string endpointId) Assert.Equal(2L, ft.SugLen(key)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task getSuggestionLengthAndDeleteSuggestionAsync(string endpointId) { @@ -3484,7 +3484,7 @@ public void TestProfileCommandBuilder() Assert.Equal(["index", "AGGREGATE", "LIMITED", "QUERY", "*"], aggregate.Args); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void Issue175(string endpointId) { @@ -3878,7 +3878,7 @@ public void TestDocumentLoad_Issue352() /// However, the key is still counted in the total number of results." /// https://redis.io/docs/latest/commands/ft.search/#:~:text=If%20a%20relevant%20key%20expires,the%20total%20number%20of%20results. /// - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public async Task TestDocumentLoadWithDB_Issue352(string endpointId) { diff --git a/tests/NRedisStack.Tests/SkipIfRedisTheoryAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisTheoryAttribute.cs index 503a329b..d7bbe4d2 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisTheoryAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisTheoryAttribute.cs @@ -1,5 +1,7 @@ +using System.Runtime.CompilerServices; using Xunit; using Xunit.Sdk; +using Xunit.v3; namespace NRedisStack.Tests; @@ -97,44 +99,157 @@ public string? Skip } } +/// +/// Override for that truncates our DisplayName down. +/// +/// Marks a test method as being a data theory. Data theories are tests which are +/// fed various bits of data from a data source, mapping to parameters on the test +/// method. If the data source contains multiple rows, then the test method is executed +/// multiple times (once with each data row). Data is provided by attributes which +/// derive from Xunit.Sdk.DataAttribute (notably, Xunit.InlineDataAttribute and Xunit.MemberDataAttribute). +/// +/// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("NRedisStack.Tests.SkippableTheoryDiscoverer", "NRedisStack.Tests")] -public class SkipIfRedisTheoryAttribute : SkippableTheoryAttribute +[XunitTestCaseDiscoverer(typeof(TheoryDiscoverer))] +public class TheoryAttribute( + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : Xunit.TheoryAttribute(sourceFilePath, sourceLineNumber) { - private readonly SkipIfRedisCore core; + public class TheoryDiscoverer : Xunit.v3.TheoryDiscoverer + { + protected override ValueTask> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute, ITheoryDataRow dataRow, object?[] testMethodArguments) + => base.CreateTestCasesForDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow, testMethodArguments).ExpandAsync(); + + protected override ValueTask> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, ITheoryAttribute theoryAttribute) + => base.CreateTestCasesForTheory(discoveryOptions, testMethod, theoryAttribute).ExpandAsync(); + } +} +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +[XunitTestCaseDiscoverer(typeof(TheoryDiscoverer))] +public class SkipIfRedisTheoryAttribute : TheoryAttribute +{ public SkipIfRedisTheoryAttribute( Is environment, Comparison comparison = Comparison.LessThan, - string targetVersion = "0.0.0") - => core = new(environment, comparison, targetVersion); - - public SkipIfRedisTheoryAttribute(string targetVersion) // defaults to LessThan - => core = new(targetVersion); + string targetVersion = "0.0.0", + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : base(sourceFilePath, sourceLineNumber) + { + SkipIfRedisCore core = new(environment, comparison, targetVersion); + Skip = core.Skip; + } - public SkipIfRedisTheoryAttribute(Comparison comparison, string targetVersion) - => core = new(comparison, targetVersion); + public SkipIfRedisTheoryAttribute( + string targetVersion, + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : base(sourceFilePath, sourceLineNumber) // defaults to LessThan + { + SkipIfRedisCore core = new(targetVersion); + Skip = core.Skip; + } - public override string? Skip => core.Skip; + public SkipIfRedisTheoryAttribute( + Comparison comparison, string targetVersion, + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : base(sourceFilePath, sourceLineNumber) + { + SkipIfRedisCore core = new(comparison, targetVersion); + Skip = core.Skip; + } } +/// +/// Override for that truncates our DisplayName down. +/// +/// Attribute that is applied to a method to indicate that it is a fact that should +/// be run by the test runner. It can also be extended to support a customized definition +/// of a test method. +/// +/// [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -[XunitTestCaseDiscoverer("NRedisStack.Tests.SkippableTheoryDiscoverer", "NRedisStack.Tests")] -public class SkipIfRedisFactAttribute : SkippableFactAttribute +[XunitTestCaseDiscoverer(typeof(FactDiscoverer))] +public class FactAttribute([CallerFilePath] string? sourceFilePath = null, [CallerLineNumber] int sourceLineNumber = -1) + : Xunit.FactAttribute(sourceFilePath, sourceLineNumber) { - private readonly SkipIfRedisCore core; + public class FactDiscoverer : Xunit.v3.FactDiscoverer + { + public override ValueTask> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) + => base.Discover(discoveryOptions, testMethod, factAttribute).ExpandAsync(); + } +} +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +[XunitTestCaseDiscoverer(typeof(FactDiscoverer))] +public class SkipIfRedisFactAttribute : FactAttribute +{ public SkipIfRedisFactAttribute( Is environment, Comparison comparison = Comparison.LessThan, - string targetVersion = "0.0.0") - => core = new(environment, comparison, targetVersion); + string targetVersion = "0.0.0", + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : base(sourceFilePath, sourceLineNumber) + { + SkipIfRedisCore core = new(environment, comparison, targetVersion); + Skip = core.Skip; + } - public SkipIfRedisFactAttribute(string targetVersion) // defaults to LessThan - => core = new(targetVersion); + public SkipIfRedisFactAttribute( // defaults to LessThan + string targetVersion, + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : base(sourceFilePath, sourceLineNumber) + { + SkipIfRedisCore core = new(targetVersion); + Skip = core.Skip; + } - public SkipIfRedisFactAttribute(Comparison comparison, string targetVersion) - => core = new(comparison, targetVersion); + public SkipIfRedisFactAttribute( + Comparison comparison, + string targetVersion, + [CallerFilePath] string? sourceFilePath = null, + [CallerLineNumber] int sourceLineNumber = -1) : base(sourceFilePath, sourceLineNumber) + { + SkipIfRedisCore core = new(comparison, targetVersion); + Skip = core.Skip; + } +} + +internal static class XUnitExtensions +{ + public static RunProtocol GetRunProtocol(this ITestContext context) => + context.Test?.TestCase is IRunProtocolTestCase protocolTestCase + ? protocolTestCase.Protocol : RunProtocol.Resp2; - public override string? Skip => core.Skip; + public static bool IsResp3(this RunProtocol protocol) => protocol is RunProtocol.Resp3 or RunProtocol.Resp3HighIntegrity; + public static bool IsHighIntegrity(this RunProtocol protocol) => protocol is RunProtocol.Resp2HighIntegrity or RunProtocol.Resp3HighIntegrity; + + public static async ValueTask> ExpandAsync(this ValueTask> discovery) + { + static IXunitTestCase CreateTestCase(XunitTestCase tc, RunProtocol protocol) => tc switch + { + XunitDelayEnumeratedTheoryTestCase delayed => new ProtocolDelayEnumeratedTestCase(delayed, protocol), + _ => new ProtocolTestCase(tc, protocol), + }; + var testCases = await discovery; + List result = []; + foreach (var testCase in testCases.OfType()) + { + var testMethod = testCase.TestMethod; + if ((testMethod.Method.GetCustomAttributes(typeof(RunPerProtocolAttribute), true).FirstOrDefault() + ?? testMethod.TestClass.Class.GetCustomAttributes(typeof(RunPerProtocolAttribute), true).FirstOrDefault()) is RunPerProtocolAttribute rpp) + { + var protocols = rpp.Protocols; + if ((protocols & RunProtocol.Resp2) != 0) result.Add(CreateTestCase(testCase, RunProtocol.Resp2)); + if ((protocols & RunProtocol.Resp3) != 0) result.Add(CreateTestCase(testCase, RunProtocol.Resp3)); + if ((protocols & RunProtocol.Resp2HighIntegrity) != 0) result.Add(CreateTestCase(testCase, RunProtocol.Resp2HighIntegrity)); + if ((protocols & RunProtocol.Resp3HighIntegrity) != 0) result.Add(CreateTestCase(testCase, RunProtocol.Resp3HighIntegrity)); + } + else + { + // Default to RESP2 everywhere else + result.Add(CreateTestCase(testCase, RunProtocol.Resp2)); + } + } + return result; + } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/SkippableTheoryDiscoverer.cs b/tests/NRedisStack.Tests/SkippableTheoryDiscoverer.cs deleted file mode 100644 index a6bfe2b8..00000000 --- a/tests/NRedisStack.Tests/SkippableTheoryDiscoverer.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Xunit.Sdk; - -namespace NRedisStack.Tests; - -// TODO(imalinovskiy): Remove this file once tests are migrated to Xunit v3 - -/// Copyright (c) Andrew Arnott. All rights reserved. -// Licensed under the Microsoft Public License (Ms-PL). -// https://github.com/AArnott/Xunit.SkippableFact/blob/main/src/Xunit.SkippableFact/Sdk/SkippableTheoryDiscoverer.cs -// See https://github.com/AArnott/Xunit.SkippableFact/blob/main/LICENSE for full license information. - -using System.Collections.Generic; -using Validation; -using Xunit.Abstractions; - -/// -/// Patched TestCase discoverer to support SkipIfRedisAttribute. -/// -public class SkippableTheoryDiscoverer : IXunitTestCaseDiscoverer -{ - /// - /// The diagnostic message sink provided to the constructor. - /// - private readonly IMessageSink diagnosticMessageSink; - - /// - /// The complex theory discovery process that we wrap. - /// - private readonly TheoryDiscoverer theoryDiscoverer; - - /// - /// Initializes a new instance of the class. - /// - /// The message sink used to send diagnostic messages. - public SkippableTheoryDiscoverer(IMessageSink diagnosticMessageSink) - { - this.diagnosticMessageSink = diagnosticMessageSink; - theoryDiscoverer = new(diagnosticMessageSink); - } - - /// - public virtual IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) - { - Requires.NotNull(factAttribute, nameof(factAttribute)); - string[] skippingExceptionNames = ["Xunit.SkippableFact.SkipException", "Xunit.SkipException"]; - TestMethodDisplay defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault(); - - IEnumerable? basis = theoryDiscoverer.Discover(discoveryOptions, testMethod, factAttribute); - foreach (IXunitTestCase? testCase in basis) - { - if (testCase is XunitTheoryTestCase) - { - yield return new SkippableTheoryTestCase(skippingExceptionNames, diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod); - } - else - { - yield return new SkippableFactTestCase(skippingExceptionNames, diagnosticMessageSink, defaultMethodDisplay, discoveryOptions.MethodDisplayOptionsOrDefault(), testCase.TestMethod, testCase.TestMethodArguments); - } - } - } -} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs index e8189335..ade49f97 100644 --- a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs +++ b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs @@ -26,7 +26,7 @@ private void AssertTotalWeight(ITdigestCommands tdigest, string key, double tota //Assert.Equal(totalWeight, 0.01); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCreateSimple(string endpointId) { @@ -47,7 +47,7 @@ public void TestCreateSimple(string endpointId) Assert.Equal(0, info.UnmergedNodes); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCreateSimpleAsync(string endpointId) { @@ -68,7 +68,7 @@ public async Task TestCreateSimpleAsync(string endpointId) Assert.Equal(0, info.UnmergedNodes); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCreateAndInfo(string endpointId) { @@ -85,7 +85,7 @@ public void TestCreateAndInfo(string endpointId) } } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCreateAndInfoAsync(string endpointId) { @@ -103,7 +103,7 @@ public async Task TestCreateAndInfoAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestRankCommands(string endpointId) { @@ -118,7 +118,7 @@ public void TestRankCommands(string endpointId) Assert.Equal(new double[] { 5, 3 }, tdigest.ByRevRank(key, 0, 1)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestRankCommandsAsync(string endpointId) { @@ -134,7 +134,7 @@ public async Task TestRankCommandsAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestReset(string endpointId) { @@ -156,7 +156,7 @@ public void TestReset(string endpointId) AssertMergedUnmergedNodes(tdigest, "reset", 0, 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestResetAsync(string endpointId) { @@ -179,7 +179,7 @@ public async Task TestResetAsync(string endpointId) AssertMergedUnmergedNodes(tdigest, "reset", 0, 0); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestAdd(string endpointId) { @@ -195,7 +195,7 @@ public void TestAdd(string endpointId) AssertMergedUnmergedNodes(tdigest, "tdadd", 0, 5); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestAddAsync(string endpointId) { @@ -299,7 +299,7 @@ public async Task MergeMultiAndParamsAsync(string endpointId) Assert.Equal(50, tdigest.Info("to").Compression); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestCDF(string endpointId) { @@ -321,7 +321,7 @@ public void TestCDF(string endpointId) tdigest.CDF("tdcdf", 25, 50, 75); // TODO: Why needed? } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestCDFAsync(string endpointId) { @@ -344,7 +344,7 @@ public async Task TestCDFAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestQuantile(string endpointId) { @@ -362,7 +362,7 @@ public void TestQuantile(string endpointId) Assert.Equal(new double[] { 1 }, tdigest.Quantile("tdqnt", 0.5)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestQuantileAsync(string endpointId) { @@ -380,7 +380,7 @@ public async Task TestQuantileAsync(string endpointId) Assert.Equal(new double[] { 1 }, await tdigest.QuantileAsync("tdqnt", 0.5)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestMinAndMax(string endpointId) { @@ -399,7 +399,7 @@ public void TestMinAndMax(string endpointId) Assert.Equal(5d, tdigest.Max(key)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestMinAndMaxAsync(string endpointId) { @@ -418,7 +418,7 @@ public async Task TestMinAndMaxAsync(string endpointId) Assert.Equal(5d, await tdigest.MaxAsync(key)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void TestTrimmedMean(string endpointId) { @@ -439,7 +439,7 @@ public void TestTrimmedMean(string endpointId) Assert.Equal(14.5, tdigest.TrimmedMean(key, 0.5, 1.0)); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task TestTrimmedMeanAsync(string endpointId) { @@ -461,7 +461,7 @@ public async Task TestTrimmedMeanAsync(string endpointId) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestModulePrefixs(string endpointId) { diff --git a/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs b/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs index cd43ee1f..28bf5210 100644 --- a/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs +++ b/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs @@ -19,7 +19,7 @@ public AuthenticationTests(EndpointsFixture endpointsFixture) : base(endpointsFi static readonly string field = "myField"; static readonly string alias = "myAlias"; - [SkippableFact] + [Fact] public void TestTokenBasedAuthentication() { // This is needed because we're constructing ConfigurationOptions in the test before calling GetConnection diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index b0b65c86..f6e69cb9 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -4,6 +4,7 @@ namespace NRedisStack.Tests.TopK; +[RunPerProtocol(RunProtocol.Resp2 | RunProtocol.Resp2HighIntegrity | RunProtocol.Resp3 | RunProtocol.Resp3HighIntegrity)] public class TopKTests : AbstractNRedisStackTest, IDisposable { private readonly string key = "TOPK_TESTS"; @@ -13,7 +14,7 @@ public TopKTests(EndpointsFixture endpointsFixture) : base(endpointsFixture) } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public void CreateTopKFilter(string endpointId) { @@ -51,7 +52,7 @@ public void CreateTopKFilter(string endpointId) Assert.Equal(2000, info.Width); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] public async Task CreateTopKFilterAsync(string endpointId) { @@ -88,7 +89,7 @@ public async Task CreateTopKFilterAsync(string endpointId) Assert.Equal(2000, info.Width); } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestModulePrefixs(string endpointId) { diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index ca7dabe1..a6bf16f0 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -14,7 +14,7 @@ public TransactionTests(EndpointsFixture endpointsFixture) : base(endpointsFixtu { } - [SkippableTheory] + [Theory] [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestJsonTransaction(string endpointId) {