From af34b9c482eb573c5fc172ab571a7f38470a327e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 10 Aug 2023 13:28:10 +0300 Subject: [PATCH 01/48] delete mock --- tests/NRedisStack.Tests/Bloom/BloomTests.cs | 2 -- tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs | 2 -- tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs | 2 -- tests/NRedisStack.Tests/Examples/ExampleTests.cs | 2 -- tests/NRedisStack.Tests/Gears/GearsTests.cs | 2 -- tests/NRedisStack.Tests/Graph/GraphTests.cs | 2 -- tests/NRedisStack.Tests/Json/JsonTests.cs | 11 ----------- tests/NRedisStack.Tests/NRedisStack.Tests.csproj | 1 - tests/NRedisStack.Tests/PipelineTests.cs | 2 -- tests/NRedisStack.Tests/Search/SearchTests.cs | 2 -- tests/NRedisStack.Tests/Tdigest/TdigestTests.cs | 2 -- tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs | 2 -- tests/NRedisStack.Tests/TopK/TopKTests.cs | 2 -- tests/NRedisStack.Tests/TransactionsTests.cs | 6 ++---- 14 files changed, 2 insertions(+), 38 deletions(-) diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index 201fb2e5..b4909b55 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.Bloom; public class BloomTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "BLOOM_TESTS"; public BloomTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs index cbef55ca..3929764e 100644 --- a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs +++ b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.CuckooFilter; public class CmsTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "CMS_TESTS"; public CmsTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index c2e74c06..685b5276 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.CuckooFilter; public class CuckooTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "CUCKOO_TESTS"; public CuckooTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index b549f0ad..49f98060 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -1,7 +1,6 @@ using System.Net.Security; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using Moq; using NRedisStack.DataTypes; using NRedisStack.RedisStackCommands; using NRedisStack.Search; @@ -21,7 +20,6 @@ namespace NRedisStack.Tests; public class ExampleTests : AbstractNRedisStackTest, IDisposable { private readonly ITestOutputHelper testOutputHelper; - Mock _mock = new Mock(); private readonly string key = "EXAMPLES_TESTS"; public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelper) : base(redisFixture) { diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 79d7f7ae..6a4b1009 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -1,12 +1,10 @@ using Xunit; using StackExchange.Redis; -using Moq; namespace NRedisStack.Tests.Gears; public class GearsTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "BLOOM_TESTS"; public GearsTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index d539de78..2f0c6af0 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -1,7 +1,6 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; using NRedisStack.Graph; using NRedisStack.Graph.DataTypes; @@ -9,7 +8,6 @@ namespace NRedisStack.Tests.Graph; public class GraphTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "GRAPH_TESTS"; public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index f437af67..f530ba4d 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -2,7 +2,6 @@ using System.Text.Json.Nodes; using Xunit; using StackExchange.Redis; -using Moq; using NRedisStack.RedisStackCommands; using NRedisStack.Json.DataTypes; @@ -10,7 +9,6 @@ namespace NRedisStack.Tests; public class JsonTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string _testName = "JSON_TESTS"; public JsonTests(RedisFixture redisFixture) : base(redisFixture) { } @@ -100,15 +98,6 @@ public void TestSetFromDirectory() Directory.Delete("BaseDir", true); } - [Fact] - public void TestJsonSetNotExist() - { - var obj = new Person { Name = "Shachar", Age = 23 }; - _mock.Setup(x => x.Execute(It.IsAny(), It.IsAny())).Returns((RedisResult.Create(new RedisValue("OK")))); - _mock.Object.JSON().Set("Person:Shachar", "$", obj, When.NotExists); - _mock.Verify(x => x.Execute("JSON.SET", "Person:Shachar", "$", "{\"Name\":\"Shachar\",\"Age\":23}", "NX")); - } - [Fact] public void TestModulePrefixs() { diff --git a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj index bc4184b6..aa4d38d6 100644 --- a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj +++ b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj @@ -20,7 +20,6 @@ all - diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 8eba3289..5eb1b079 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -1,7 +1,6 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; using System.Text.Json; using NRedisStack.Search; @@ -9,7 +8,6 @@ namespace NRedisStack.Tests; public class PipelineTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "PIPELINE_TESTS"; public PipelineTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 9d2e4eb9..94107829 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -1,7 +1,6 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; using NRedisStack.Search; using static NRedisStack.Search.Schema; using NRedisStack.Search.Aggregation; @@ -12,7 +11,6 @@ namespace NRedisStack.Tests.Search; public class SearchTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); // private readonly string key = "SEARCH_TESTS"; private readonly string index = "TEST_INDEX"; public SearchTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs index 99f866b3..c5a47cd8 100644 --- a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs +++ b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.Tdigest; public class TdigestTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TDIGEST_TESTS"; public TdigestTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs index dbaca333..7e8b568a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs @@ -1,14 +1,12 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.TimeSeries; public class TimeSeriesTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TIME_SERIES_TESTS"; public TimeSeriesTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 5f720a97..f51e4f9f 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -1,13 +1,11 @@ using Xunit; using StackExchange.Redis; using NRedisStack.RedisStackCommands; -using Moq; namespace NRedisStack.Tests.TopK; public class TopKTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TOPK_TESTS"; public TopKTests(RedisFixture redisFixture) : base(redisFixture) { } diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 32533126..3a741852 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -1,5 +1,4 @@ -using Moq; -using NRedisStack.RedisStackCommands; +using NRedisStack.RedisStackCommands; using NRedisStack.Search; using StackExchange.Redis; using System.Text.Json; @@ -9,8 +8,7 @@ namespace NRedisStack.Tests { public class TransactionTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); - private readonly string key = "TRX_TESTS"; + private readonly string key = "TRX_TESTS"; public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() From ff101b573f7d0801305b019eb5e70067a1389a41 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 10 Aug 2023 14:09:13 +0300 Subject: [PATCH 02/48] coverage --- tests/NRedisStack.Tests/Json/JsonTests.cs | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index f530ba4d..c4834ee4 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -98,6 +98,34 @@ public void TestSetFromDirectory() Directory.Delete("BaseDir", true); } + [Fact] + public void TestJsonSetNotExist() + { + //arrange + var conn = redisFixture.Redis; + var db = conn.GetDatabase(); + IJsonCommands commands = new JsonCommands(db); + + var obj = new Person { Name = "Shachar", Age = 23 }; + Assert.True(commands.Set("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(commands.Set("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(commands.Set("Person:Shachar", "$", obj, When.Exists)); + } + + [Fact] + public async Task TestJsonSetNotExistAsync() + { + //arrange + var conn = redisFixture.Redis; + var db = conn.GetDatabase(); + IJsonCommandsAsync commands = new JsonCommands(db); + + var obj = new Person { Name = "Shachar", Age = 23 }; + Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); + } + [Fact] public void TestModulePrefixs() { From c2b5fe6957550bb1491273aac48a1d74ca00f298 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 10 Aug 2023 14:49:38 +0300 Subject: [PATCH 03/48] fix test --- tests/NRedisStack.Tests/Json/JsonTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index c4834ee4..1532a84b 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -105,11 +105,12 @@ public void TestJsonSetNotExist() var conn = redisFixture.Redis; var db = conn.GetDatabase(); IJsonCommands commands = new JsonCommands(db); + db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; Assert.True(commands.Set("Person:Shachar", "$", obj, When.NotExists)); Assert.False(commands.Set("Person:Shachar", "$", obj, When.NotExists)); - Assert.False(commands.Set("Person:Shachar", "$", obj, When.Exists)); + Assert.True(commands.Set("Person:Shachar", "$", obj, When.Exists)); } [Fact] @@ -119,11 +120,12 @@ public async Task TestJsonSetNotExistAsync() var conn = redisFixture.Redis; var db = conn.GetDatabase(); IJsonCommandsAsync commands = new JsonCommands(db); + db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); - Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); + Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); } [Fact] From f8f2aecc31bb0c43ae4d2edf56ff325bdd2dcb04 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 13 Aug 2023 15:56:53 +0300 Subject: [PATCH 04/48] indent --- tests/NRedisStack.Tests/TransactionsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 3a741852..dbfc61e4 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -8,7 +8,7 @@ namespace NRedisStack.Tests { public class TransactionTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "TRX_TESTS"; + private readonly string key = "TRX_TESTS"; public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() From 27a69c0bc5f7a46b84f6bff06ec4b9cb8ed56f05 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 14 Aug 2023 15:09:47 +0300 Subject: [PATCH 05/48] change to var - check --- tests/NRedisStack.Tests/Json/JsonTests.cs | 104 +++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 69cd141e..2fd6f74b 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -23,7 +23,7 @@ public void TestSetFromFile() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(1); //creating json string: @@ -51,7 +51,7 @@ public void TestSetFromDirectory() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); //creating json string: object[] persons = new object[10]; @@ -104,7 +104,7 @@ public void TestJsonSetNotExist() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; @@ -119,7 +119,7 @@ public async Task TestJsonSetNotExistAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommands(db); + var commands = new JsonCommands(db); db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; @@ -146,7 +146,7 @@ public void TestResp() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(1); var key = keys[0]; @@ -171,7 +171,7 @@ public async Task TestRespAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); var key = keys[0]; @@ -196,7 +196,7 @@ public void TestStringAppend() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -224,7 +224,7 @@ public async Task TestStringAppendAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -252,7 +252,7 @@ public void StringLength() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleStringKey = keys[1]; @@ -277,7 +277,7 @@ public async Task StringLengthAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleStringKey = keys[1]; @@ -302,7 +302,7 @@ public void Toggle() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -324,7 +324,7 @@ public async Task ToggleAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -346,7 +346,7 @@ public void Type() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -370,7 +370,7 @@ public async Task TypeAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -393,7 +393,7 @@ public void ArrayAppend() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -411,7 +411,7 @@ public async Task ArrayAppendAsync() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -429,7 +429,7 @@ public void ArrayIndex() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommands commands = new JsonCommands(db); + var commands = new JsonCommands(db); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { name = "Elizabeth", nicknames = new[] { "Beth", "Betty", "Liz" }, sibling = new { name = "Johnathan", nicknames = new[] { "Jon", "Johnny" } } }); @@ -443,7 +443,7 @@ public async Task ArrayIndexAsync() { var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { name = "Elizabeth", nicknames = new[] { "Beth", "Betty", "Liz" }, sibling = new { name = "Johnathan", nicknames = new[] { "Jon", "Johnny" } } }); @@ -455,7 +455,7 @@ public async Task ArrayIndexAsync() [Fact] public void ArrayInsert() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -472,7 +472,7 @@ public void ArrayInsert() [Fact] public async Task ArrayInsertAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -489,7 +489,7 @@ public async Task ArrayInsertAsync() [Fact] public void ArrayLength() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -505,7 +505,7 @@ public void ArrayLength() [Fact] public async Task ArrayLengthAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -521,7 +521,7 @@ public async Task ArrayLengthAsync() [Fact] public void ArrayPop() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -539,7 +539,7 @@ public void ArrayPop() [Fact] public async Task ArrayPopAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -557,7 +557,7 @@ public async Task ArrayPopAsync() [Fact] public void ArrayTrim() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -573,7 +573,7 @@ public void ArrayTrim() [Fact] public async Task ArrayTrimAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -589,7 +589,7 @@ public async Task ArrayTrimAsync() [Fact] public void Clear() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -605,7 +605,7 @@ public void Clear() [Fact] public async Task ClearAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -621,7 +621,7 @@ public async Task ClearAsync() [Fact] public void Del() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -637,7 +637,7 @@ public void Del() [Fact] public async Task DelAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -653,7 +653,7 @@ public async Task DelAsync() [Fact] public void Forget() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -669,7 +669,7 @@ public void Forget() [Fact] public async Task ForgetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -685,7 +685,7 @@ public async Task ForgetAsync() [Fact] public void Get() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -705,7 +705,7 @@ public void Get() [Fact] public async Task GetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key = keys[0]; var complexKey = keys[1]; @@ -725,7 +725,7 @@ public async Task GetAsync() [SkipIfRedisVersion("7.1.242")] public void MSet() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -749,7 +749,7 @@ public void MSet() [SkipIfRedisVersion("7.1.242")] public async Task MSetAsync() { - IJsonCommandsAsync commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -773,7 +773,7 @@ await commands.MSetAsync(values) public void Merge() { // Create a connection to Redis - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); Assert.True(commands.Merge("test_merge", "$", new { person = new { age = 30 } })); @@ -792,7 +792,7 @@ public void Merge() public async Task MergeAsync() { // Create a connection to Redis - IJsonCommandsAsync commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); Assert.True(await commands.MergeAsync("test_merge", "$", new { person = new { age = 30 } })); @@ -810,7 +810,7 @@ public async Task MergeAsync() [Fact] public void MGet() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -825,7 +825,7 @@ public void MGet() [Fact] public async Task MGetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -840,7 +840,7 @@ public async Task MGetAsync() [Fact] public void NumIncrby() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { age = 33, a = new { age = 34 }, b = new { age = "cat" } }); @@ -853,7 +853,7 @@ public void NumIncrby() [Fact] public async Task NumIncrbyAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { age = 33, a = new { age = 34 }, b = new { age = "cat" } }); @@ -866,7 +866,7 @@ public async Task NumIncrbyAsync() [Fact] public void ObjectKeys() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; commands.Set(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -884,7 +884,7 @@ public void ObjectKeys() [Fact] public async Task ObjectKeysAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; await commands.SetAsync(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -902,7 +902,7 @@ public async Task ObjectKeysAsync() [Fact] public void ObjectLength() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; commands.Set(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -918,7 +918,7 @@ public void ObjectLength() [Fact] public async Task ObjectLengthAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(3); var key = keys[0]; await commands.SetAsync(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -934,7 +934,7 @@ public async Task ObjectLengthAsync() [Fact] public void TestMultiPathGet() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { a = "hello", b = new { a = "world" } }); @@ -958,7 +958,7 @@ public void TestMultiPathGet() [Fact] public async Task TestMultiPathGetAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { a = "hello", b = new { a = "world" } }); @@ -982,7 +982,7 @@ public async Task TestMultiPathGetAsync() [Fact] public void Memory() { - IJsonCommands commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; @@ -996,7 +996,7 @@ public void Memory() [Fact] public async Task MemoryAsync() { - IJsonCommandsAsync commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); var keys = CreateKeyNames(1); var key = keys[0]; @@ -1013,7 +1013,7 @@ public async Task TestSetFromFileAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); //creating json string: @@ -1041,7 +1041,7 @@ public async Task TestSetFromDirectoryAsync() //arrange var conn = redisFixture.Redis; var db = conn.GetDatabase(); - IJsonCommandsAsync commands = new JsonCommandsAsync(db); + var commands = new JsonCommandsAsync(db); //creating json string: object[] persons = new object[10]; From dc0d3c0187c48423a510336c6727daeaa0c0fee8 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 14 Aug 2023 17:51:46 +0300 Subject: [PATCH 06/48] cluster test --- .../Clusters/ClusterTests.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/NRedisStack.Tests/Clusters/ClusterTests.cs diff --git a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs new file mode 100644 index 00000000..2a0a59c7 --- /dev/null +++ b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs @@ -0,0 +1,42 @@ +using StackExchange.Redis; +using Xunit; + +namespace NRedisStack.Tests; + +public class ClusterTests : AbstractNRedisStackTest, IDisposable +{ + private readonly string key = "CLUSTER_TESTS"; + public ClusterTests(RedisFixture redisFixture) : base(redisFixture) { } + + public void Dispose() + { + redisFixture.Redis.GetDatabase().KeyDelete(key); + } + + [Fact(Skip = "This test needs to run on a cluster")] + public void ClusterConnect() + { + // first, run a cluster, + ConfigurationOptions config = new ConfigurationOptions + { + // ports: 16379 -> 16384 + EndPoints = + { + { "127.0.0.1", 16379 }, + { "127.0.0.1", 16380 }, + { "127.0.0.1", 16381 }, + { "127.0.0.1", 16382 }, + { "127.0.0.1", 16383 }, + { "127.0.0.1", 16384 }, + }, + }; + var conn = ConnectionMultiplexer.Connect(config); + IDatabase clusterDB = conn.GetDatabase(); + clusterDB.KeyDelete("foo"); + clusterDB.StringSet("foo", "bar"); + var value = clusterDB.StringGet("foo"); + Assert.Equal("bar", value); + // var endpoints = conn.GetEndPoints(); + // Console.WriteLine("endpoints:" + endpoints.ToString()); + } +} From eeb2edf7204e2a19ab556af4557ab65db5e0d66d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 15 Aug 2023 17:08:19 +0300 Subject: [PATCH 07/48] add opthin to connect cluster with dotnet test --- tests/NRedisStack.Tests/RedisFixture.cs | 39 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index 8ae470f2..297e60ad 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -1,14 +1,47 @@ +using System.Net; +using Org.BouncyCastle.Tls; using StackExchange.Redis; namespace NRedisStack.Tests { public class RedisFixture : IDisposable { + // Set the enviroment variable to specify your own alternet host and port: + string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); + string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); + // bool redisClusterMode = false; // TODO: check if this is needed + + public RedisFixture() + { + // Redis Cluster + if (redisCluster != null && numRedisClusterNodesEnv != null) + { + // Split to host and port + string[] parts = redisCluster.Split(':'); + string host = parts[0]; + int startPort = int.Parse(parts[1]); + var endpoints = new EndPointCollection(); + int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv); + for (int i = 0; i < numRedisClusterNodes; i++) + { + endpoints.Add(host, startPort + i); + } - // Set the enviroment variable to specify your own alternet host and port: - string redis = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - public RedisFixture() => Redis = ConnectionMultiplexer.Connect($"{redis}"); + + ConfigurationOptions clusterConfig = new ConfigurationOptions + { + EndPoints = endpoints + }; + // redisClusterMode = true; + Redis = ConnectionMultiplexer.Connect(clusterConfig); + } + + // Redis Standalone + else + Redis = ConnectionMultiplexer.Connect($"{redisStandalone}"); + } public void Dispose() { From 0d100d7545ced4f0a68386b26bdc32bc2300a4e7 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 16 Aug 2023 15:10:58 +0300 Subject: [PATCH 08/48] use key in topk tests --- tests/NRedisStack.Tests/TopK/TopKTests.cs | 39 ++++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index f51e4f9f..5d8220c2 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -21,30 +21,31 @@ public void CreateTopKFilter() db.Execute("FLUSHALL"); var topk = db.TOPK(); - topk.Reserve("aaa", 30, 2000, 7, 0.925); + //db.KeyDelete(key, CommandFlags.FireAndForget); + topk.Reserve(key, 30, 2000, 7, 0.925); - var res = topk.Add("aaa", "bb", "cc"); + var res = topk.Add(key, "bb", "cc"); Assert.True(res[0].IsNull && res[1].IsNull); - Assert.Equal(topk.Query("aaa", "bb", "gg", "cc"), new bool[] { true, false, true }); - Assert.False(topk.Query("aaa", "notExists")); + Assert.Equal(topk.Query(key, "bb", "gg", "cc"), new bool[] { true, false, true }); + Assert.False(topk.Query(key, "notExists")); - Assert.Equal(topk.Count("aaa", "bb", "gg", "cc"), new long[] { 1, 0, 1 }); + Assert.Equal(topk.Count(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); - var res2 = topk.List("aaa"); + var res2 = topk.List(key); Assert.Equal(res2[0].ToString(), "bb"); Assert.Equal(res2[1].ToString(), "cc"); var tuple = new Tuple("ff", 10); - var del = topk.IncrBy("aaa", tuple); - Assert.True(topk.IncrBy("aaa", tuple)[0].IsNull); + var del = topk.IncrBy(key, tuple); + Assert.True(topk.IncrBy(key, tuple)[0].IsNull); - res2 = topk.List("aaa"); + res2 = topk.List(key); Assert.Equal(res2[0].ToString(), "ff"); Assert.Equal(res2[1].ToString(), "bb"); Assert.Equal(res2[2].ToString(), "cc"); - var info = topk.Info("aaa"); + var info = topk.Info(key); Assert.Equal(info.Decay, 0.925); Assert.Equal(info.Depth, 7); Assert.Equal(info.K, 30); @@ -58,29 +59,29 @@ public async Task CreateTopKFilterAsync() db.Execute("FLUSHALL"); var topk = db.TOPK(); - await topk.ReserveAsync("aaa", 30, 2000, 7, 0.925); + await topk.ReserveAsync(key, 30, 2000, 7, 0.925); - var res = await topk.AddAsync("aaa", "bb", "cc"); + var res = await topk.AddAsync(key, "bb", "cc"); Assert.True(res[0].IsNull && res[1].IsNull); - Assert.Equal(await topk.QueryAsync("aaa", "bb", "gg", "cc"), new bool[] { true, false, true }); - Assert.False(await topk.QueryAsync("aaa", "notExists")); + Assert.Equal(await topk.QueryAsync(key, "bb", "gg", "cc"), new bool[] { true, false, true }); + Assert.False(await topk.QueryAsync(key, "notExists")); - Assert.Equal(await topk.CountAsync("aaa", "bb", "gg", "cc"), new long[] { 1, 0, 1 }); + Assert.Equal(await topk.CountAsync(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); - var res2 = await topk.ListAsync("aaa"); + var res2 = await topk.ListAsync(key); Assert.Equal(res2[0].ToString(), "bb"); Assert.Equal(res2[1].ToString(), "cc"); var tuple = new Tuple("ff", 10); - Assert.True((await topk.IncrByAsync("aaa", tuple))[0].IsNull); + Assert.True((await topk.IncrByAsync(key, tuple))[0].IsNull); - res2 = await topk.ListAsync("aaa"); + res2 = await topk.ListAsync(key); Assert.Equal(res2[0].ToString(), "ff"); Assert.Equal(res2[1].ToString(), "bb"); Assert.Equal(res2[2].ToString(), "cc"); - var info = await topk.InfoAsync("aaa"); + var info = await topk.InfoAsync(key); Assert.Equal(info.Decay, 0.925); Assert.Equal(info.Depth, 7); Assert.Equal(info.K, 30); From 02d183769d02cc262db232716294a43bc12ac484 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 22 Aug 2023 14:24:51 +0300 Subject: [PATCH 09/48] get env vars inside RedisFixture --- tests/NRedisStack.Tests/RedisFixture.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index 297e60ad..f52c87e1 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -6,14 +6,13 @@ namespace NRedisStack.Tests { public class RedisFixture : IDisposable { - // Set the enviroment variable to specify your own alternet host and port: - string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); - string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); - // bool redisClusterMode = false; // TODO: check if this is needed - public RedisFixture() { + // Set the enviroment variable to specify your own alternet host and port: + var redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + var redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); + var numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); + // bool redisClusterMode = false; // TODO: check if this is needed // Redis Cluster if (redisCluster != null && numRedisClusterNodesEnv != null) { From 65a49b62c925b3a3e20edff6af06de34d02a558d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 22 Aug 2023 17:20:57 +0300 Subject: [PATCH 10/48] skip if redis --- .../Examples/ExampleTests.cs | 14 +- tests/NRedisStack.Tests/Gears/GearsTests.cs | 14 +- tests/NRedisStack.Tests/Graph/GraphTests.cs | 128 ++++++++--------- tests/NRedisStack.Tests/Json/JsonTests.cs | 8 +- tests/NRedisStack.Tests/PipelineTests.cs | 2 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 130 +++++++++--------- .../NRedisStack.Tests/SkipIfRedisAttribute.cs | 109 +++++++++++++++ .../SkipIfRedisVersionAttribute.cs | 55 -------- tests/NRedisStack.Tests/TransactionsTests.cs | 2 +- 9 files changed, 258 insertions(+), 204 deletions(-) create mode 100644 tests/NRedisStack.Tests/SkipIfRedisAttribute.cs delete mode 100644 tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 49f98060..14d11a58 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -31,7 +31,7 @@ public void Dispose() redisFixture.Redis.GetDatabase().KeyDelete(key); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void HSETandSearch() { // Connect to the Redis server @@ -132,7 +132,7 @@ public void PipelineExample() Assert.Equal(expected, result.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task JsonWithSearchPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -176,7 +176,7 @@ public async Task JsonWithSearchPipeline() // Assert.Equal("person:01", firstPerson?.Id); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task PipelineWithAsync() { // Connect to the Redis server @@ -234,7 +234,7 @@ public async Task PipelineWithAsync() Assert.Equal("temp:JLM", respons[0].key); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TransactionExample() { // Connect to the Redis server @@ -278,7 +278,7 @@ public async Task TransactionExample() Assert.Equal("[1200]", totalAmtOfShachar.Result.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestJsonConvert() { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); @@ -960,7 +960,7 @@ public void AdvancedJsonExamplesTest() Assert.Equal(expected, res.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void BasicQueryOperationsTest() { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); @@ -1120,7 +1120,7 @@ public void BasicQueryOperationsTest() Assert.Equal(expected, res[0].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void AdvancedQueryOperationsTest() { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 9651f53e..9070f3ad 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -14,7 +14,7 @@ public void Dispose() } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestTFunctionLoadDelete() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -24,7 +24,7 @@ public void TestTFunctionLoadDelete() } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public async Task TestTFunctionLoadDeleteAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -35,7 +35,7 @@ public async Task TestTFunctionLoadDeleteAsync() Assert.True(await db.TFunctionDeleteAsync("lib")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestTFunctionList() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -66,7 +66,7 @@ public void TestTFunctionList() Assert.True(db.TFunctionDelete("lib3")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public async Task TestTFunctionListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -95,7 +95,7 @@ public async Task TestTFunctionListAsync() Assert.True(await db.TFunctionDeleteAsync("lib3")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestTFCall() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -109,7 +109,7 @@ public void TestTFCall() Assert.True(db.TFunctionDelete("lib")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public async Task TestTFCallAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -123,7 +123,7 @@ public async Task TestTFCallAsync() Assert.True(await db.TFunctionDeleteAsync("lib")); } - [SkipIfRedisVersion(Comparison.LessThan, "7.1.242")] + [SkipIfRedis(Comparison.LessThan, "7.1.242")] public void TestGearsCommandBuilder() { // TFunctionLoad: diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 05df345f..3b3edf56 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -18,7 +18,7 @@ public void Dispose() #region SyncTests - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestReserveBasic() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -26,7 +26,7 @@ public void TestReserveBasic() var graph = db.GRAPH(); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCreateNode() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -49,7 +49,7 @@ public void TestCreateNode() graph.Delete("social"); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCreateLabeledNode() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -70,7 +70,7 @@ public void TestCreateLabeledNode() // Assert.False(resultSet..iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestConnectNodes() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -97,7 +97,7 @@ public void TestConnectNodes() Assert.Equal(0, resultSet.Count); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestDeleteNodes() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -144,7 +144,7 @@ public void TestDeleteNodes() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestDeleteRelationship() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -174,7 +174,7 @@ public void TestDeleteRelationship() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestIndex() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -201,7 +201,7 @@ public void TestIndex() Assert.Equal(1, deleteExistingIndexResult.Statistics.IndicesDeleted); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestHeader() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -232,7 +232,7 @@ public void TestHeader() Assert.Equal("a.age", schemaNames[2]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestRecord() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -357,7 +357,7 @@ public void TestRecord() } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestAdditionToProcedures() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -437,7 +437,7 @@ record = iterator.Current; Assert.Equal(expectedEdge.ToString(), record.Values[1].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestEscapedQuery() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -456,7 +456,7 @@ public void TestEscapedQuery() Assert.NotNull(graph.Query("social", "MATCH (n) where n.s1='S\"' RETURN n")); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestArraySupport() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -556,7 +556,7 @@ record = iterator.Current; } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestPath() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -608,7 +608,7 @@ public void TestPath() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestNullGraphEntities() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -662,7 +662,7 @@ record = resultSet.Skip(1).First(); Assert.Null(record.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void Test64BitNumber() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -680,7 +680,7 @@ public void Test64BitNumber() } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCachedExecution() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -711,7 +711,7 @@ public void TestCachedExecution() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestMapDataType() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -741,7 +741,7 @@ public void TestMapDataType() Assert.Equal((object)expected, actual); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestGeoPointLatLon() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -755,7 +755,7 @@ public void TestGeoPointLatLon() AssertTestGeoPoint(graph); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestGeoPointLonLat() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -784,7 +784,7 @@ private void AssertTestGeoPoint(IGraphCommands graph) Assert.Equal((object)(point), property); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestPoint() { var point = new Point(30.27822306, -97.75134723); @@ -796,7 +796,7 @@ public void TestPoint() Assert.Throws(() => new Point(new List { 1, 2, 3 })); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void timeoutArgument() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -810,7 +810,7 @@ public void timeoutArgument() Assert.Equal(100l, (long)r.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCachedExecutionReadOnly() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -843,7 +843,7 @@ public void TestCachedExecutionReadOnly() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestSimpleReadOnly() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -858,7 +858,7 @@ public void TestSimpleReadOnly() Assert.Equal("30", r.Values[0].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestProfile() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -876,7 +876,7 @@ public void TestProfile() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestExplain() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -894,7 +894,7 @@ public void TestExplain() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestSlowlog() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -909,7 +909,7 @@ public void TestSlowlog() slowlogs.ForEach(sl => sl.ForEach(s => Assert.NotNull(s))); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestList() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -922,7 +922,7 @@ public void TestList() Assert.Equal(new List() { "social" }, graph.List()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -942,7 +942,7 @@ public void TestConfig() graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestModulePrefixs() { IDatabase db1 = redisFixture.Redis.GetDatabase(); @@ -954,7 +954,7 @@ public void TestModulePrefixs() Assert.NotEqual(graph1.GetHashCode(), graph2.GetHashCode()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCallProcedureDbLabels() { var db = redisFixture.Redis.GetDatabase(); @@ -975,7 +975,7 @@ public void TestCallProcedureDbLabels() Assert.Single(labels1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestCallProcedureReadOnly() { var db = redisFixture.Redis.GetDatabase(); @@ -1001,7 +1001,7 @@ public void TestCallProcedureReadOnly() #region AsyncTests - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestReserveBasicAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1009,7 +1009,7 @@ public async Task TestReserveBasicAsync() var graph = db.GRAPH(); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCreateNodeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1032,7 +1032,7 @@ public async Task TestCreateNodeAsync() await graph.DeleteAsync("social"); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCreateLabeledNodeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1053,7 +1053,7 @@ public async Task TestCreateLabeledNodeAsync() // Assert.False(resultSet..iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestConnectNodesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1081,7 +1081,7 @@ public async Task TestConnectNodesAsync() // Assert.False(resultSet.GetEnumerator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestDeleteNodesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1128,7 +1128,7 @@ public async Task TestDeleteNodesAsync() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestDeleteRelationshipAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1158,7 +1158,7 @@ public async Task TestDeleteRelationshipAsync() // Assert.False(deleteResult.iterator().MoveNext()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestIndexAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1185,7 +1185,7 @@ public async Task TestIndexAsync() Assert.Equal(1, deleteExistingIndexResult.Statistics.IndicesDeleted); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestHeaderAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1216,7 +1216,7 @@ public async Task TestHeaderAsync() Assert.Equal("a.age", schemaNames[2]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestRecordAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1343,7 +1343,7 @@ await graph.QueryAsync("social", "MATCH (a:person), (b:person) WHERE (a.name = ' } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestAdditionToProceduresAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1423,7 +1423,7 @@ record = iterator.Current; Assert.Equal(expectedEdge.ToString(), record.Values[1].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestEscapedQueryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1442,7 +1442,7 @@ public async Task TestEscapedQueryAsync() Assert.NotNull(await graph.QueryAsync("social", "MATCH (n) where n.s1='S\"' RETURN n")); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestArraySupportAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1542,7 +1542,7 @@ record = iterator.Current; } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestPathAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1594,7 +1594,7 @@ public async Task TestPathAsync() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestNullGraphEntitiesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1648,7 +1648,7 @@ record = resultSet.Skip(1).First(); Assert.Null(record.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task Test64bitnumberAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1666,7 +1666,7 @@ public async Task Test64bitnumberAsync() } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCachedExecutionAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1697,7 +1697,7 @@ public async Task TestCachedExecutionAsync() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestMapDataTypeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1727,7 +1727,7 @@ public async Task TestMapDataTypeAsync() Assert.Equal((object)expected, actual); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestGeoPointLatLonAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1741,7 +1741,7 @@ public async Task TestGeoPointLatLonAsync() AssertTestGeoPoint(graph); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestGeoPointLonLatAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1769,7 +1769,7 @@ private async Task AssertTestGeoPointAsync(GraphCommands graph) Assert.Equal((object)(new Point(30.27822306, -97.75134723)), property); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task timeoutArgumentAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1783,7 +1783,7 @@ public async Task timeoutArgumentAsync() Assert.Equal(100l, (long)r.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCachedExecutionReadOnlyAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1816,7 +1816,7 @@ public async Task TestCachedExecutionReadOnlyAsync() Assert.True(resultSet.Statistics.CachedExecution); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestSimpleReadOnlyAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1831,7 +1831,7 @@ public async Task TestSimpleReadOnlyAsync() Assert.Equal("30", r.Values[0].ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestProfileAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1849,7 +1849,7 @@ public async Task TestProfileAsync() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestExplainAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1867,7 +1867,7 @@ public async Task TestExplainAsync() } } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestSlowlogAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1882,7 +1882,7 @@ public async Task TestSlowlogAsync() slowlogs.ForEach(sl => sl.ForEach(s => Assert.NotNull(s))); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1895,7 +1895,7 @@ public async Task TestListAsync() Assert.Equal(new List() { "social" }, await graph.ListAsync()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestConfigAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1915,7 +1915,7 @@ public async Task TestConfigAsync() await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulePrefixsAsync() { IDatabase db1 = redisFixture.Redis.GetDatabase(); @@ -1927,7 +1927,7 @@ public async Task TestModulePrefixsAsync() Assert.NotEqual(graph1.GetHashCode(), graph2.GetHashCode()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCallProcedureDbLabelsAsync() { var db = redisFixture.Redis.GetDatabase(); @@ -1948,7 +1948,7 @@ public async Task TestCallProcedureDbLabelsAsync() Assert.Single(labels1); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestCallProcedureReadOnlyAsync() { var db = redisFixture.Redis.GetDatabase(); @@ -1970,7 +1970,7 @@ public async Task TestCallProcedureReadOnlyAsync() await Assert.ThrowsAsync(() => graph.CallProcedureAsync(graphName, "db.idx.fulltext.createNodeIndex", procedureArgs, ProcedureMode.Read)); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestParseInfinity() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1984,7 +1984,7 @@ public void TestParseInfinity() Assert.Equal(double.PositiveInfinity, r.Values[0]); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestEqualsAndToString() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2061,7 +2061,7 @@ public void TestEqualsAndToString() Assert.Equal(expectedPathString, pathString); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public void TestPrepareQuery() { const string return1Query = "RETURN 1"; diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 2fd6f74b..1fe517d5 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -722,7 +722,7 @@ public async Task GetAsync() Assert.Equal(35, people[1]!.Age); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public void MSet() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -746,7 +746,7 @@ public void MSet() Assert.Throws(() => commands.MSet(new KeyPathValue[0])); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public async Task MSetAsync() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -769,7 +769,7 @@ await commands.MSetAsync(values) await Assert.ThrowsAsync(async () => await commands.MSetAsync(new KeyPathValue[0])); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public void Merge() { // Create a connection to Redis @@ -788,7 +788,7 @@ public void Merge() Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"phone\":\"123-456-7890\",\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"}}}", commands.Get("test_merge").ToString()); } - [SkipIfRedisVersion("7.1.242")] + [SkipIfRedis("7.1.242")] public async Task MergeAsync() { // Create a connection to Redis diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 0100faad..945e6b62 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -16,7 +16,7 @@ public void Dispose() redisFixture.Redis.GetDatabase().KeyDelete(key); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulsPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index fe471c4b..a1dafb82 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -149,7 +149,7 @@ public async Task TestAggregationRequestTimeoutAsync() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAggregations() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -190,7 +190,7 @@ public void TestAggregations() Assert.Equal(10, r2.GetLong("sum")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationsAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -232,7 +232,7 @@ public async Task TestAggregationsAsync() } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAggregationsLoad() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -260,7 +260,7 @@ public void TestAggregationsLoad() Assert.Equal(res[0]["t2"], "world"); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationsLoadAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -322,7 +322,7 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(10, r1.GetLong("sum")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationRequestParamsDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -390,7 +390,7 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(10, r1.GetLong("sum")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAggregationRequestParamsWithDefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -411,7 +411,7 @@ public async Task TestAggregationRequestParamsWithDefaultDialectAsync() AggregationRequest r = new AggregationRequest("$name") .GroupBy("@name", Reducers.Sum("@count").As("sum")) .Params(parameters); // From documentation - To use PARAMS, DIALECT must be set to 2 - // which is the default as we set in the constructor (FT(2)) + // which is the default as we set in the constructor (FT(2)) AggregationResult res = await ft.AggregateAsync(index, r); Assert.Equal(1, res.TotalResults); @@ -431,7 +431,7 @@ public void TestDefaultDialectError() Assert.Throws(() => db.FT(0)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAlias() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -460,7 +460,7 @@ public void TestAlias() Assert.Throws(() => ft.AliasDel("ALIAS2")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAliasAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -489,7 +489,7 @@ public async Task TestAliasAsync() await Assert.ThrowsAsync(async () => await ft.AliasDelAsync("ALIAS2")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestApplyAndFilterAggregations() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -533,7 +533,7 @@ public void TestApplyAndFilterAggregations() Assert.Equal(67.5, r2.GetDouble("avgscore"), 0); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestCreate() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -565,7 +565,7 @@ public void TestCreate() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCreateAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -591,7 +591,7 @@ public async Task TestCreateAsync() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void CreateNoParams() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -619,7 +619,7 @@ public void CreateNoParams() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task CreateNoParamsAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -647,7 +647,7 @@ public async Task CreateNoParamsAsync() Assert.Equal(0, res3.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void CreateWithFieldNames() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -679,7 +679,7 @@ public void CreateWithFieldNames() Assert.Equal(1, nonAttribute.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task CreateWithFieldNamesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -711,7 +711,7 @@ public async Task CreateWithFieldNamesAsync() Assert.Equal(1, nonAttribute.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void AlterAdd() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -775,7 +775,7 @@ public void AlterAdd() Assert.Equal(4, info.CursorStats.Count); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task AlterAddAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -859,7 +859,7 @@ public async Task TestConfigAsnyc() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void configOnTimeout() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -883,7 +883,7 @@ public async Task configOnTimeoutAsync() try { ft.ConfigSet("ON_TIMEOUT", "null"); } catch (RedisServerException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDialectConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -905,7 +905,7 @@ public void TestDialectConfig() Assert.True(ft.ConfigSet("DEFAULT_DIALECT", "1")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestDialectConfigAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -927,7 +927,7 @@ public async Task TestDialectConfigAsync() Assert.True(ft.ConfigSet("DEFAULT_DIALECT", "1")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCursor() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -989,7 +989,7 @@ public async Task TestCursor() catch (RedisException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCursorAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1051,7 +1051,7 @@ public async Task TestCursorAsync() catch (RedisException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAggregationGroupBy() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1159,7 +1159,7 @@ public void TestAggregationGroupBy() } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDictionary() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1178,7 +1178,7 @@ public void TestDictionary() Assert.Equal(ft.DictDump("dict").Length, 0); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDropIndex() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1211,7 +1211,7 @@ public void TestDropIndex() Assert.Equal("100", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestDropIndexAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1244,7 +1244,7 @@ public async Task TestDropIndexAsync() Assert.Equal("100", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void dropIndexDD() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1270,7 +1270,7 @@ public void dropIndexDD() Assert.Equal("0", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task dropIndexDDAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1296,7 +1296,7 @@ public async Task dropIndexDDAsync() Assert.Equal("0", db.Execute("DBSIZE").ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestDictionaryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1507,7 +1507,7 @@ public void TestModulePrefixs() Assert.NotEqual(ft1.GetHashCode(), ft2.GetHashCode()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task GetTagFieldSyncAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1565,7 +1565,7 @@ public async Task GetTagFieldSyncAsync() Assert.Equal(SyncRes[i++].ToString(), "yellow"); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1692,7 +1692,7 @@ public void TestFTCreateParamsCommandBuilderNoStopwords() Assert.Equal("FT.CREATE", builedCommand.Command.ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestFilters() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1742,7 +1742,7 @@ public void TestFilters() Assert.Equal("doc1", res1.Documents[0].Id); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestFiltersAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1926,7 +1926,7 @@ public void TestQueryCommandBuilderReturnField() Assert.Equal(0, res.Documents.Count()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestQueryCommandBuilderScore() { // TODO: write better test for scores and payloads @@ -2001,7 +2001,7 @@ public void TestFieldsCommandBuilder() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestLimit() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2021,7 +2021,7 @@ public void TestLimit() Assert.Equal(res.GetResults()[0]["t1"].ToString(), "a"); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestLimitAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2093,7 +2093,7 @@ public async Task TestVectorCount_Issue70() Assert.Equal(expected.Count(), actual.Args.Length); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void VectorSimilaritySearch() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2136,7 +2136,7 @@ public void VectorSimilaritySearch() Assert.Equal("{\"vector\":[2,2,2,2]}", jsonRes![0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void QueryingVectorFields() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2184,7 +2184,7 @@ public async Task TestVectorFieldJson_Issue102Async() Assert.True(await ft.CreateAsync("my_index", new FTCreateParams().On(IndexDataType.JSON), schema)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestQueryAddParam_DefaultDialect() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2203,7 +2203,7 @@ public void TestQueryAddParam_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestQueryAddParam_DefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2222,7 +2222,7 @@ public async Task TestQueryAddParam_DefaultDialectAsync() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestQueryParamsWithParams_DefaultDialect() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2250,7 +2250,7 @@ public void TestQueryParamsWithParams_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestBasicSpellCheck() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2270,7 +2270,7 @@ public void TestBasicSpellCheck() Assert.Equal(2, reply["name"]["name2"]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestBasicSpellCheckAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2290,7 +2290,7 @@ public async Task TestBasicSpellCheckAsync() Assert.Equal(2, reply["name"]["name2"]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestCrossTermDictionary() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2314,7 +2314,7 @@ public void TestCrossTermDictionary() .ExcludeTerm("slang"))); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestCrossTermDictionaryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2338,7 +2338,7 @@ public async Task TestCrossTermDictionaryAsync() .ExcludeTerm("slang"))); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestDistanceBound() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2386,7 +2386,7 @@ public async Task TestDialectBoundAsync() await Assert.ThrowsAsync(async () => await ft.SpellCheckAsync(index, "name", new FTSpellCheckParams().Dialect(0))); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestQueryParamsWithParams_DefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2651,7 +2651,7 @@ public void TestProfileSearch() var profile = ft.ProfileSearch(index, new Query("foo")); // Iterators profile={Type=TEXT, Time=0.0, Term=foo, Counter=1, Size=1} profile.Item2["Iterators profile"].ToDictionary(); - var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); + var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); Assert.Equal("TEXT", iteratorsProfile["Type"].ToString()); Assert.Equal("foo", iteratorsProfile["Term"].ToString()); Assert.Equal("1", iteratorsProfile["Counter"].ToString()); @@ -2675,7 +2675,7 @@ public async Task TestProfileSearchAsync() var profile = await ft.ProfileSearchAsync(index, new Query("foo")); // Iterators profile={Type=TEXT, Time=0.0, Term=foo, Counter=1, Size=1} profile.Item2["Iterators profile"].ToDictionary(); - var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); + var iteratorsProfile = profile.Item2["Iterators profile"].ToDictionary(); Assert.Equal("TEXT", iteratorsProfile["Type"].ToString()); Assert.Equal("foo", iteratorsProfile["Term"].ToString()); Assert.Equal("1", iteratorsProfile["Counter"].ToString()); @@ -2690,9 +2690,9 @@ public void TestProfile() db.Execute("FLUSHALL"); var ft = db.FT(); - ft.Create(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams - db.HashSet("1", "t", "hello"); - db.HashSet("2", "t", "world"); + ft.Create(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams + db.HashSet("1", "t", "hello"); + db.HashSet("2", "t", "world"); // check using Query var q = new Query("hello|world").SetNoContent(); @@ -2700,15 +2700,15 @@ public void TestProfile() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count , 5); - Assert.Equal(searchRes.Documents.Count , 2); + Assert.Equal(searchDet.Count, 5); + Assert.Equal(searchRes.Documents.Count, 2); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = ft.ProfileAggregate(index, aggReq); - var aggregateRes  = profileAggregate.Item1; + var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count , 5); + Assert.Equal(aggregateDet.Count, 5); Assert.Equal(aggregateRes.TotalResults, 1); } @@ -2719,9 +2719,9 @@ public async Task TestProfileAsync() db.Execute("FLUSHALL"); var ft = db.FT(); - await ft.CreateAsync(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams - db.HashSet("1", "t", "hello"); - db.HashSet("2", "t", "world"); + await ft.CreateAsync(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams + db.HashSet("1", "t", "hello"); + db.HashSet("2", "t", "world"); // check using Query var q = new Query("hello|world").SetNoContent(); @@ -2729,15 +2729,15 @@ public async Task TestProfileAsync() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count , 5); - Assert.Equal(searchRes.Documents.Count , 2); + Assert.Equal(searchDet.Count, 5); + Assert.Equal(searchRes.Documents.Count, 2); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = await ft.ProfileAggregateAsync(index, aggReq); - var aggregateRes  = profileAggregate.Item1; + var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count , 5); + Assert.Equal(aggregateDet.Count, 5); Assert.Equal(aggregateRes.TotalResults, 1); } @@ -2753,7 +2753,7 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void Issue175() { ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs new file mode 100644 index 00000000..55b63ee2 --- /dev/null +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -0,0 +1,109 @@ +using Xunit; +using StackExchange.Redis; +using NRedisStack.Tests; +using System.Text; + +public enum Comparison +{ + LessThan, + GreaterThanOrEqual, +} + +public enum Is +{ + Standalone, + Cluster +} + +[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] +public class SkipIfRedisAttribute : FactAttribute +{ + private readonly string _targetVersion; + private readonly Comparison _comparison; + private readonly Is? _is = null; + private readonly string DefaultRedisConnectionString = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + + public SkipIfRedisAttribute( + Is _is, + Comparison comparison = Comparison.LessThan, + string targetVersion = "0.0.0") + { + this._is = _is; + _comparison = comparison; + _targetVersion = targetVersion; + } + + public SkipIfRedisAttribute(string targetVersion) // defaults to LessThan + { + _comparison = Comparison.LessThan; + _targetVersion = targetVersion; + } + + public SkipIfRedisAttribute(Comparison comparison, string targetVersion) + { + _comparison = comparison; + _targetVersion = targetVersion; + } + + public override string? Skip + { + get + { + using (var connection = ConnectionMultiplexer.Connect(DefaultRedisConnectionString)) + { + string skipReason = ""; + bool skipped = false; + + // Cluster check + if (_is != null) + { + bool isCluster = connection.GetEndPoints().Length > 1; + switch (_is) + { + case Is.Cluster: + if (isCluster) + { + skipReason = skipReason + " Redis server is a cluster."; + skipped = true; + } + break; + + case Is.Standalone: + if (!isCluster) + { + skipReason = skipReason + " Redis server is not a cluster."; + skipped = true; + } + break; + } + } + // Version check (if Is.Standalone/Is.Cluster is set then ) + var serverVersion = connection.GetServer(connection.GetEndPoints()[0]).Version; + var targetVersion = new Version(_targetVersion); + int comparisonResult = serverVersion.CompareTo(targetVersion); + + switch (_comparison) + { + case Comparison.LessThan: + if (comparisonResult < 0) + { + skipReason = skipReason + $" Redis server version ({serverVersion}) is less than {_targetVersion}."; + skipped = true; + } + break; + case Comparison.GreaterThanOrEqual: + if (comparisonResult >= 0) + { + skipReason = skipReason + $" Redis server version ({serverVersion}) is greater than or equal to {_targetVersion}."; + skipped = true; + } + break; + } + + if (skipped) + return "Test skipped, because:" + skipReason; + return null; + } + } + } +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs deleted file mode 100644 index 6d19bc2c..00000000 --- a/tests/NRedisStack.Tests/SkipIfRedisVersionAttribute.cs +++ /dev/null @@ -1,55 +0,0 @@ -using Xunit; -using StackExchange.Redis; - -public enum Comparison -{ - LessThan, - GreaterThanOrEqual, -} - -[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -public class SkipIfRedisVersionAttribute : FactAttribute -{ - private readonly string _targetVersion; - private readonly Comparison _comparison; - private readonly string DefaultRedisConnectionString = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - - public SkipIfRedisVersionAttribute(string targetVersion) // defaults to LessThan - { - _comparison = Comparison.LessThan; - _targetVersion = targetVersion; - } - - public SkipIfRedisVersionAttribute(Comparison comparison, string targetVersion) - { - _comparison = comparison; - _targetVersion = targetVersion; - } - - public override string Skip - { - get - { - using (var connection = ConnectionMultiplexer.Connect(DefaultRedisConnectionString)) - { - var serverVersion = connection.GetServer(connection.GetEndPoints()[0]).Version; - var targetVersion = new Version(_targetVersion); - int comparisonResult = serverVersion.CompareTo(targetVersion); - - switch (_comparison) - { - case Comparison.LessThan: - if (comparisonResult < 0) - return $"Test skipped because Redis server version ({serverVersion}) is less than {_targetVersion}."; - break; - case Comparison.GreaterThanOrEqual: - if (comparisonResult >= 0) - return $"Test skipped because Redis server version ({serverVersion}) is greater than or equal to {_targetVersion}."; - break; - } - - return null; - } - } - } -} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 26f3d8aa..e25913c8 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -32,7 +32,7 @@ public async Task TestJsonTransaction() Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString()); } - [SkipIfRedisVersion(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulsTransaction() { IDatabase db = redisFixture.Redis.GetDatabase(); From c7b6cd9e30782e028547934ae9caad16a474c2f6 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:34:14 +0300 Subject: [PATCH 11/48] add skip where needed --- .../AbstractNRedisStackTest.cs | 3 ++- tests/NRedisStack.Tests/Bloom/BloomTests.cs | 2 +- .../Clusters/ClusterTests.cs | 14 +++++++++-- .../CountMinSketch/CmsTests.cs | 6 ++--- .../CuckooFilter/CuckooTests.cs | 2 +- .../Examples/ExampleTests.cs | 2 +- tests/NRedisStack.Tests/Gears/GearsTests.cs | 20 +++++++++++----- tests/NRedisStack.Tests/Graph/GraphTests.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 8 +++---- tests/NRedisStack.Tests/PipelineTests.cs | 6 ++--- tests/NRedisStack.Tests/Search/SearchTests.cs | 18 +++++++------- .../NRedisStack.Tests/SkipIfRedisAttribute.cs | 22 ++++++++--------- .../NRedisStack.Tests/Tdigest/TdigestTests.cs | 10 ++++---- .../TimeSeries/TestAPI/TestAdd.cs | 2 +- .../TimeSeries/TestAPI/TestAlter.cs | 2 +- .../TimeSeries/TestAPI/TestCreate.cs | 2 +- .../TimeSeries/TestAPI/TestDecrBy.cs | 2 +- .../TimeSeries/TestAPI/TestDel.cs | 2 +- .../TimeSeries/TestAPI/TestGet.cs | 2 +- .../TimeSeries/TestAPI/TestIncrBy.cs | 2 +- .../TimeSeries/TestAPI/TestMADD.cs | 8 +++---- .../TimeSeries/TestAPI/TestMAddAsync.cs | 6 ++--- .../TimeSeries/TestAPI/TestMGet.cs | 8 +++---- .../TimeSeries/TestAPI/TestMGetAsync.cs | 4 ++-- .../TimeSeries/TestAPI/TestMRange.cs | 22 ++++++++--------- .../TimeSeries/TestAPI/TestMRangeAsync.cs | 24 +++++++++---------- .../TimeSeries/TestAPI/TestMRevRange.cs | 24 +++++++++---------- .../TimeSeries/TestAPI/TestMRevRangeAsync.cs | 24 +++++++++---------- .../TimeSeries/TestAPI/TestQueryIndex.cs | 4 ++-- .../TimeSeries/TestAPI/TestQueryIndexAsync.cs | 2 +- .../TimeSeries/TestAPI/TestRange.cs | 6 ++--- .../TimeSeries/TestAPI/TestRangeAsync.cs | 4 ++-- .../TimeSeries/TestAPI/TestRules.cs | 6 ++--- .../TimeSeries/TestAPI/TestRulesAsync.cs | 4 ++-- .../TimeSeries/TimeSeriesTests.cs | 2 +- tests/NRedisStack.Tests/TopK/TopKTests.cs | 2 +- tests/NRedisStack.Tests/TransactionsTests.cs | 4 ++-- 37 files changed, 152 insertions(+), 131 deletions(-) diff --git a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs index b84d259a..ac9e079d 100644 --- a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs +++ b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs @@ -46,7 +46,8 @@ protected internal static List ReverseData(List (RedisKey)i).ToArray()); + // await redis.KeyDeleteAsync(keyNames.Select(i => (RedisKey)i).ToArray()); + await redis.ExecuteBroadcastAsync("FLUSHALL"); } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index b4909b55..3812461b 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -11,7 +11,7 @@ public BloomTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs index 2a0a59c7..42e65bd1 100644 --- a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs +++ b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs @@ -10,10 +10,10 @@ public ClusterTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } - [Fact(Skip = "This test needs to run on a cluster")] + [SkipIfRedis(Is.Standalone)] public void ClusterConnect() { // first, run a cluster, @@ -39,4 +39,14 @@ public void ClusterConnect() // var endpoints = conn.GetEndPoints(); // Console.WriteLine("endpoints:" + endpoints.ToString()); } + + [Fact] + public void ClusterChecks() + { + var db = redisFixture.Redis.GetDatabase(); + var endpoints1 = db.Multiplexer.GetEndPoints(); + var endpoints2 = redisFixture.Redis.GetEndPoints(); + var isCtr = redisFixture.isCluster; + var isCtr2 = ""; + } } diff --git a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs index 3929764e..2e9a47ec 100644 --- a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs +++ b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs @@ -11,7 +11,7 @@ public CmsTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] @@ -215,7 +215,7 @@ public async Task TestQueryAsync() Assert.Equal(new long[] { 10, 15 }, resp); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMerge() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -264,7 +264,7 @@ public void TestMerge() } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMergeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 685b5276..4d1a7db3 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -11,7 +11,7 @@ public CuckooTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 14d11a58..e771f702 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -28,7 +28,7 @@ public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelpe public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [SkipIfRedis(Is.Cluster)] diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 9070f3ad..c448b0b0 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -5,12 +5,12 @@ namespace NRedisStack.Tests.Gears; public class GearsTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "BLOOM_TESTS"; + private readonly string key = "GEARS_TESTS"; public GearsTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } @@ -18,6 +18,7 @@ public void Dispose() public void TestTFunctionLoadDelete() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); Assert.True(db.TFunctionLoad(GenerateLibCode("lib"))); Assert.True(db.TFunctionDelete("lib")); @@ -28,6 +29,7 @@ public void TestTFunctionLoadDelete() public async Task TestTFunctionLoadDeleteAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -39,6 +41,7 @@ public async Task TestTFunctionLoadDeleteAsync() public void TestTFunctionList() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -70,6 +73,7 @@ public void TestTFunctionList() public async Task TestTFunctionListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -99,6 +103,7 @@ public async Task TestTFunctionListAsync() public void TestTFCall() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -113,6 +118,7 @@ public void TestTFCall() public async Task TestTFCallAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); + db.ExecuteBroadcast("REDISGEARS_2.REFRESHCLUSTER"); db.Execute("FLUSHALL"); TryDeleteLib(db, "lib", "lib1", "lib2", "lib3"); @@ -187,12 +193,14 @@ public void TestGearsCommandBuilder() private static void TryDeleteLib(IDatabase db, params string[] libNames) { - try + foreach (var libName in libNames) { - foreach(var libName in libNames) - db.TFunctionDelete(libName); + try + { + db.ExecuteBroadcast(GearsCommandBuilder.TFunctionDelete(libName)); + } + catch (RedisServerException) { } // ignore } - catch (RedisServerException) { } } private static string GenerateLibCode(string libName) diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 3b3edf56..08a9f42d 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -13,7 +13,7 @@ public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } #region SyncTests diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 1fe517d5..718afb0d 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -722,7 +722,7 @@ public async Task GetAsync() Assert.Equal(35, people[1]!.Age); } - [SkipIfRedis("7.1.242")] + [SkipIfRedis(Is.Cluster, Comparison.LessThan, "7.1.242")] public void MSet() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -746,7 +746,7 @@ public void MSet() Assert.Throws(() => commands.MSet(new KeyPathValue[0])); } - [SkipIfRedis("7.1.242")] + [SkipIfRedis(Is.Cluster, Comparison.LessThan, "7.1.242")] public async Task MSetAsync() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -807,7 +807,7 @@ public async Task MergeAsync() Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"phone\":\"123-456-7890\",\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"}}}", (await commands.GetAsync("test_merge")).ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void MGet() { var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); @@ -822,7 +822,7 @@ public void MGet() Assert.Equal("[\"world\"]", result[1].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task MGetAsync() { var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 945e6b62..6279f7d8 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -13,10 +13,10 @@ public PipelineTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } - [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Is.Cluster, Comparison.GreaterThanOrEqual, "7.1.242")] public async Task TestModulsPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -67,7 +67,7 @@ public async Task TestModulsPipeline() Assert.NotNull(db.TOPK().Info("topk-key")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestModulsPipelineWithotGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index a1dafb82..fca6b388 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -17,7 +17,9 @@ public SearchTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(index); + // redisFixture.Redis.GetDatabase().KeyDelete(index); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); + } private void AddDocument(IDatabase db, Document doc) @@ -322,7 +324,7 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.Cluster)] + [Fact] public async Task TestAggregationRequestParamsDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -390,7 +392,7 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.Cluster)] + [Fact] public async Task TestAggregationRequestParamsWithDefaultDialectAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -859,7 +861,7 @@ public async Task TestConfigAsnyc() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void configOnTimeout() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2250,7 +2252,7 @@ public void TestQueryParamsWithParams_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void TestBasicSpellCheck() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2270,7 +2272,7 @@ public void TestBasicSpellCheck() Assert.Equal(2, reply["name"]["name2"]); } - [SkipIfRedis(Is.Cluster)] + [Fact] public async Task TestBasicSpellCheckAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2338,7 +2340,7 @@ public async Task TestCrossTermDictionaryAsync() .ExcludeTerm("slang"))); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void TestDistanceBound() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2753,7 +2755,7 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [SkipIfRedis(Is.Cluster)] + [Fact] public void Issue175() { ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs index 55b63ee2..8b035f13 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -49,19 +49,18 @@ public override string? Skip { get { - using (var connection = ConnectionMultiplexer.Connect(DefaultRedisConnectionString)) + string skipReason = ""; + bool skipped = false; + using (RedisFixture redisFixture = new RedisFixture()) { - string skipReason = ""; - bool skipped = false; // Cluster check if (_is != null) { - bool isCluster = connection.GetEndPoints().Length > 1; switch (_is) { case Is.Cluster: - if (isCluster) + if (redisFixture.isCluster) { skipReason = skipReason + " Redis server is a cluster."; skipped = true; @@ -69,7 +68,7 @@ public override string? Skip break; case Is.Standalone: - if (!isCluster) + if (!redisFixture.isCluster) { skipReason = skipReason + " Redis server is not a cluster."; skipped = true; @@ -78,7 +77,8 @@ public override string? Skip } } // Version check (if Is.Standalone/Is.Cluster is set then ) - var serverVersion = connection.GetServer(connection.GetEndPoints()[0]).Version; + + var serverVersion = redisFixture.Redis.GetServer(redisFixture.Redis.GetEndPoints()[0]).Version; var targetVersion = new Version(_targetVersion); int comparisonResult = serverVersion.CompareTo(targetVersion); @@ -99,11 +99,11 @@ public override string? Skip } break; } - - if (skipped) - return "Test skipped, because:" + skipReason; - return null; } + + if (skipped) + return "Test skipped, because:" + skipReason; + return null; } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs index c5a47cd8..9343f04f 100644 --- a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs +++ b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs @@ -11,7 +11,7 @@ public TdigestTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } private void AssertMergedUnmergedNodes(ITdigestCommands tdigest, string key, int mergedNodes, int unmergedNodes) @@ -370,7 +370,7 @@ public async Task TestAddAsync() AssertMergedUnmergedNodes(tdigest, "tdadd", 0, 5); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMerge() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -393,7 +393,7 @@ public void TestMerge() } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMergeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -416,7 +416,7 @@ public async Task TestMergeAsync() AssertMergedUnmergedNodes(tdigest, "td2", 3, 2); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void MergeMultiAndParams() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -437,7 +437,7 @@ public void MergeMultiAndParams() Assert.Equal(50, tdigest.Info("to").Compression); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task MergeMultiAndParamsAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs index 31c6450a..1daea83f 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs @@ -13,7 +13,7 @@ public TestAdd(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index 7a37562b..ce15694c 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -14,7 +14,7 @@ public TestAlter(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs index 7f7bfb19..47380ecc 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs @@ -14,7 +14,7 @@ public TestCreate(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs index 3b84174b..124afda6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs @@ -13,7 +13,7 @@ public TestDecrBy(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs index d779052c..b98fd526 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs @@ -14,7 +14,7 @@ public TestDel(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } private List CreateData(ITimeSeriesCommands ts, int timeBucket) //TODO: check this diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs index 5fee7e96..faae70cc 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs @@ -14,7 +14,7 @@ public TestGet(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs index c31794fe..06fc7eb1 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs @@ -13,7 +13,7 @@ public TestIncrBy(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs index e2a22064..67cd1444 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs @@ -17,11 +17,11 @@ public void Dispose() { foreach (string key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestStarMADD() { @@ -50,7 +50,7 @@ public void TestStarMADD() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestSuccessfulMADD() { @@ -80,7 +80,7 @@ public void TestSuccessfulMADD() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestOverrideMADD() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs index 5d5ce9c5..a91dadea 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs @@ -11,7 +11,7 @@ public class TestMAddAsync : AbstractNRedisStackTest public TestMAddAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestStarMADD() { var keys = CreateKeyNames(2); @@ -43,7 +43,7 @@ public async Task TestStarMADD() } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestSuccessfulMAdd() { var keys = CreateKeyNames(2); @@ -73,7 +73,7 @@ public async Task TestSuccessfulMAdd() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestOverrideMAdd() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs index 658bd242..ab78ac32 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs @@ -16,11 +16,11 @@ public void Dispose() { foreach (string key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMGetQuery() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -47,7 +47,7 @@ public void TestMGetQuery() } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMGetQueryWithLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -74,7 +74,7 @@ public void TestMGetQueryWithLabels() Assert.Equal(labels2, results[1].labels); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMGetQuerySelectedLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs index 0057eab8..fc24abe6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs @@ -8,7 +8,7 @@ public class TestMGetAsync : AbstractNRedisStackTest { public TestMGetAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMGetQuery() { var keys = CreateKeyNames(2); @@ -64,7 +64,7 @@ public async Task TestMGetQueryWithLabels() Assert.Equal(labels2, results[1].labels); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMGetQuerySelectedLabelsAsync() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs index dfbb079c..e1fcd75a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs @@ -16,7 +16,7 @@ public void Dispose() { foreach (string key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } @@ -36,7 +36,7 @@ private List CreateData(ITimeSeriesCommands ts, int timeBucket) return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestSimpleMRange() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -59,7 +59,7 @@ public void TestSimpleMRange() Assert.Equal(tuples, results[i].values); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeWithLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -83,7 +83,7 @@ public void TestMRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeSelectLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -112,7 +112,7 @@ public void TestMRangeSelectLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeFilter() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -129,7 +129,7 @@ public void TestMRangeFilter() Assert.Equal(tuples, results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeCount() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -154,7 +154,7 @@ public void TestMRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeAggregation() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -178,7 +178,7 @@ public void TestMRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeAlign() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -237,7 +237,7 @@ public void TestMissingTimeBucket() Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeGroupby() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -263,7 +263,7 @@ public void TestMRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeReduce() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -288,7 +288,7 @@ public void TestMRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRangeFilterBy() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs index 175ffd68..3ea53529 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs @@ -27,7 +27,7 @@ private async Task> CreateData(TimeSeriesCommands ts, stri return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestSimpleMRange() { var keys = CreateKeyNames(2); @@ -51,7 +51,7 @@ public async Task TestSimpleMRange() Assert.Equal(tuples, results[i].values); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeWithLabels() { var keys = CreateKeyNames(2); @@ -76,7 +76,7 @@ public async Task TestMRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeSelectLabels() { var keys = CreateKeyNames(2); @@ -110,7 +110,7 @@ await ts.MRangeAsync("-", "+", } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeFilter() { var keys = CreateKeyNames(2); @@ -128,7 +128,7 @@ public async Task TestMRangeFilter() Assert.Equal(tuples, results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeCount() { var keys = CreateKeyNames(2); @@ -154,7 +154,7 @@ public async Task TestMRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeAggregation() { var keys = CreateKeyNames(2); @@ -179,7 +179,7 @@ public async Task TestMRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeAlign() { var keys = CreateKeyNames(2); @@ -203,7 +203,7 @@ public async Task TestMRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingFilter() { var keys = CreateKeyNames(2); @@ -222,7 +222,7 @@ public async Task TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingTimeBucket() { var keys = CreateKeyNames(2); @@ -245,7 +245,7 @@ await ts.MRangeAsync("-", "+", }); Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeGroupby() { var keys = CreateKeyNames(2); @@ -272,7 +272,7 @@ public async Task TestMRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeReduce() { var keys = CreateKeyNames(2); @@ -298,7 +298,7 @@ public async Task TestMRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeFilterBy() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs index afd31cfe..638ca4e2 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs @@ -27,7 +27,7 @@ private List CreateData(ITimeSeriesCommands ts, string[] keys, return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestSimpleMRevRange() { var keys = CreateKeyNames(2); @@ -52,7 +52,7 @@ public void TestSimpleMRevRange() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeWithLabels() { var keys = CreateKeyNames(2); @@ -78,7 +78,7 @@ public void TestMRevRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeSelectLabels() { var keys = CreateKeyNames(2); @@ -103,7 +103,7 @@ public void TestMRevRangeSelectLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeFilter() { var keys = CreateKeyNames(2); @@ -121,7 +121,7 @@ public void TestMRevRangeFilter() Assert.Equal(ReverseData(tuples), results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeCount() { var keys = CreateKeyNames(2); @@ -147,7 +147,7 @@ public void TestMRevRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeAggregation() { var keys = CreateKeyNames(2); @@ -172,7 +172,7 @@ public void TestMRevRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeAlign() { var keys = CreateKeyNames(2); @@ -196,7 +196,7 @@ public void TestMRevRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMissingFilter() { var keys = CreateKeyNames(2); @@ -215,7 +215,7 @@ public void TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMissingTimeBucket() { var keys = CreateKeyNames(2); @@ -234,7 +234,7 @@ public void TestMissingTimeBucket() Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeGroupby() { var keys = CreateKeyNames(2); @@ -261,7 +261,7 @@ public void TestMRevRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeReduce() { var keys = CreateKeyNames(2); @@ -288,7 +288,7 @@ public void TestMRevRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestMRevRangeFilterBy() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs index 5c30b3e7..a7409fc4 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs @@ -27,7 +27,7 @@ private async Task> CreateData(TimeSeriesCommands ts, stri return tuples; } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestSimpleMRevRange() { var keys = CreateKeyNames(2); @@ -52,7 +52,7 @@ public async Task TestSimpleMRevRange() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeWithLabels() { var keys = CreateKeyNames(2); @@ -77,7 +77,7 @@ public async Task TestMRevRangeWithLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeSelectLabels() { var keys = CreateKeyNames(2); @@ -102,7 +102,7 @@ public async Task TestMRevRangeSelectLabels() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeFilter() { var keys = CreateKeyNames(2); @@ -120,7 +120,7 @@ public async Task TestMRevRangeFilter() Assert.Equal(ReverseData(tuples), results[0].values); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeCount() { var keys = CreateKeyNames(2); @@ -146,7 +146,7 @@ public async Task TestMRevRangeCount() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRangeAggregation() { var keys = CreateKeyNames(2); @@ -171,7 +171,7 @@ public async Task TestMRangeAggregation() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeAlign() { var keys = CreateKeyNames(2); @@ -195,7 +195,7 @@ public async Task TestMRevRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingFilter() { var keys = CreateKeyNames(2); @@ -214,7 +214,7 @@ public async Task TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMissingTimeBucket() { var keys = CreateKeyNames(2); @@ -238,7 +238,7 @@ await ts.MRevRangeAsync("-", "+", Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeGroupby() { var keys = CreateKeyNames(2); @@ -265,7 +265,7 @@ public async Task TestMRevRangeGroupby() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeReduce() { var keys = CreateKeyNames(2); @@ -292,7 +292,7 @@ public async Task TestMRevRangeReduce() } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestMRevRangeFilterBy() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs index ac7fbb75..572badd7 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs @@ -14,11 +14,11 @@ public void Dispose() { foreach (var key in keys) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestTSQueryIndex() { var db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs index 2fe89e8f..92385573 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs @@ -8,7 +8,7 @@ public class TestQueryIndexAsync : AbstractNRedisStackTest { public TestQueryIndexAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestTSQueryIndex() { var keys = CreateKeyNames(2); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs index f831ddb0..dc6c43ff 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs @@ -14,7 +14,7 @@ public TestRange(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } private List CreateData(ITimeSeriesCommands ts, int timeBucket) @@ -130,7 +130,7 @@ public void TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void latest() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -165,7 +165,7 @@ public void latest() Assert.Equal(new List() { latest, compact }, ts.RevRange("ts2", 0, 10, true)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAlignTimestamp() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs index 67a1c009..9b052eec 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs @@ -129,7 +129,7 @@ public async Task TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestLatestAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -164,7 +164,7 @@ public async Task TestLatestAsync() Assert.Equal(new List() { latest, compact }, await ts.RevRangeAsync("ts2", 0, 10, true)); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAlignTimestampAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs index c8c4779f..fad0d0ad 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs @@ -37,11 +37,11 @@ public void Dispose() redisFixture.Redis.GetDatabase().KeyDelete(srcKey); foreach (var key in destKeys.Values) { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestRulesAdditionDeletion() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -104,7 +104,7 @@ public void TestNonExisitingDestinaion() Assert.Equal("ERR TSDB: compaction rule does not exist", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestAlignTimestamp() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs index 3e2c5e91..42a2ece5 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs @@ -10,7 +10,7 @@ public class TestRulesAsync : AbstractNRedisStackTest { public TestRulesAsync(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestRulesAdditionDeletion() { var key = CreateKeyName(); @@ -88,7 +88,7 @@ public async Task TestNonExisitingDestinaion() Assert.Equal("ERR TSDB: compaction rule does not exist", ex.Message); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestAlignTimestampAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs index 7e8b568a..d7c0686f 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs @@ -12,7 +12,7 @@ public TimeSeriesTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } // [Fact] diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 5d8220c2..87ab2bac 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -11,7 +11,7 @@ public TopKTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index e25913c8..48d9dd14 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -13,7 +13,7 @@ public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } public void Dispose() { - redisFixture.Redis.GetDatabase().KeyDelete(key); + redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); } [Fact] @@ -83,7 +83,7 @@ public async Task TestModulsTransaction() Assert.NotNull(db.TOPK().Info("topk-key")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestModulsTransactionWithoutGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); From 6e82630bd413b648cce4359aeceeb1f5fa0309c6 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:34:38 +0300 Subject: [PATCH 12/48] Execute broadcast --- src/NRedisStack/Auxiliary.cs | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/NRedisStack/Auxiliary.cs b/src/NRedisStack/Auxiliary.cs index 2dcde416..75f1fd5d 100644 --- a/src/NRedisStack/Auxiliary.cs +++ b/src/NRedisStack/Auxiliary.cs @@ -35,5 +35,53 @@ public async static Task ExecuteAsync(this IDatabaseAsync db, Seria { return await db.ExecuteAsync(command.Command, command.Args); } + + public static List ExecuteBroadcast(this IDatabaseAsync db, string command) + => db.ExecuteBroadcast(new SerializedCommand(command)); + + public static List ExecuteBroadcast(this IDatabaseAsync db, SerializedCommand command) + { + var redis = db.Multiplexer; + var endpoints = redis.GetEndPoints(); + var results = new List(endpoints.Length); + + foreach (var endPoint in endpoints) + { + var server = redis.GetServer(endPoint); + + if (server.IsReplica) + { + continue; // Skip replica nodes + } + // Send your command to the master node + + results.Add(server.Multiplexer.GetDatabase().Execute(command)); + } + return results; + } + + public async static Task> ExecuteBroadcastAsync(this IDatabaseAsync db, string command) + => await db.ExecuteBroadcastAsync(new SerializedCommand(command)); + + public async static Task> ExecuteBroadcastAsync(this IDatabaseAsync db, SerializedCommand command) + { + var redis = db.Multiplexer; + var endpoints = redis.GetEndPoints(); + var results = new List(endpoints.Length); + + foreach (var endPoint in endpoints) + { + var server = redis.GetServer(endPoint); + + if (server.IsReplica) + { + continue; // Skip replica nodes + } + // Send your command to the master node + + results.Add(await server.Multiplexer.GetDatabase().ExecuteAsync(command)); + } + return results; + } } } \ No newline at end of file From b5cdf871a44f7c16a418a4593fde21dd5fb4a71c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:41:00 +0300 Subject: [PATCH 13/48] delete cluster tests --- .../Clusters/ClusterTests.cs | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 tests/NRedisStack.Tests/Clusters/ClusterTests.cs diff --git a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs b/tests/NRedisStack.Tests/Clusters/ClusterTests.cs deleted file mode 100644 index 42e65bd1..00000000 --- a/tests/NRedisStack.Tests/Clusters/ClusterTests.cs +++ /dev/null @@ -1,52 +0,0 @@ -using StackExchange.Redis; -using Xunit; - -namespace NRedisStack.Tests; - -public class ClusterTests : AbstractNRedisStackTest, IDisposable -{ - private readonly string key = "CLUSTER_TESTS"; - public ClusterTests(RedisFixture redisFixture) : base(redisFixture) { } - - public void Dispose() - { - redisFixture.Redis.GetDatabase().ExecuteBroadcast("FLUSHALL"); - } - - [SkipIfRedis(Is.Standalone)] - public void ClusterConnect() - { - // first, run a cluster, - ConfigurationOptions config = new ConfigurationOptions - { - // ports: 16379 -> 16384 - EndPoints = - { - { "127.0.0.1", 16379 }, - { "127.0.0.1", 16380 }, - { "127.0.0.1", 16381 }, - { "127.0.0.1", 16382 }, - { "127.0.0.1", 16383 }, - { "127.0.0.1", 16384 }, - }, - }; - var conn = ConnectionMultiplexer.Connect(config); - IDatabase clusterDB = conn.GetDatabase(); - clusterDB.KeyDelete("foo"); - clusterDB.StringSet("foo", "bar"); - var value = clusterDB.StringGet("foo"); - Assert.Equal("bar", value); - // var endpoints = conn.GetEndPoints(); - // Console.WriteLine("endpoints:" + endpoints.ToString()); - } - - [Fact] - public void ClusterChecks() - { - var db = redisFixture.Redis.GetDatabase(); - var endpoints1 = db.Multiplexer.GetEndPoints(); - var endpoints2 = redisFixture.Redis.GetEndPoints(); - var isCtr = redisFixture.isCluster; - var isCtr2 = ""; - } -} From 376ccdf1df42e6709c905c9ea19b021975a2e2fd Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:41:11 +0300 Subject: [PATCH 14/48] RedisFixture fix --- tests/NRedisStack.Tests/RedisFixture.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs index b09172d5..22a1de3e 100644 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ b/tests/NRedisStack.Tests/RedisFixture.cs @@ -6,23 +6,24 @@ namespace NRedisStack.Tests { public class RedisFixture : IDisposable { + // Set the enviroment variable to specify your own alternet host and port: + string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; + string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); + string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); + public bool isCluster = false; + public RedisFixture() { - // Set the enviroment variable to specify your own alternet host and port: - var redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - var redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); - var numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); - // bool redisClusterMode = false; // TODO: check if this is needed // Redis Cluster if (redisCluster != null && numRedisClusterNodesEnv != null) { // Split to host and port - string[] parts = redisCluster.Split(':'); + string[] parts = redisCluster!.Split(':'); string host = parts[0]; int startPort = int.Parse(parts[1]); var endpoints = new EndPointCollection(); - int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv); + int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv!); for (int i = 0; i < numRedisClusterNodes; i++) { endpoints.Add(host, startPort + i); @@ -33,7 +34,7 @@ public RedisFixture() { EndPoints = endpoints }; - // redisClusterMode = true; + isCluster = true; Redis = ConnectionMultiplexer.Connect(clusterConfig); } From 495dce1f5f550cd2c94651ae7774190a5be7ad4f Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 24 Aug 2023 14:45:51 +0300 Subject: [PATCH 15/48] add to contributing --- CONTRIBUTING.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e3b2a3ba..8dc83bd9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,6 +112,15 @@ e.g: ```bash dotnet test --environment="REDIS=172.17.0.1:6379" ``` + +If you want to run your tests against an oss cluster, you can do it thus: +```bash +dotnet test --environment "REDIS_CLUSTER=" --environment "NUM_REDIS_CLUSTER_NODES=" +``` +e.g. : +```bash +dotnet test --environment "REDIS_CLUSTER=127.0.0.1:16379" --environment "NUM_REDIS_CLUSTER_NODES=6" +``` ## How to Report a Bug ### Security Vulnerabilities From 47e2d7f957a36fc80b6567686093924b700a192e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 13:56:05 +0300 Subject: [PATCH 16/48] run cluster on CI --- .devcontainer/docker-compose.yml | 2 +- .github/docker-compose.yml | 30 +++++++++++++ .github/dockers/Dockerfile.cluster | 7 +++ .github/dockers/cluster.redis.conf | 8 ++++ .github/dockers/create_cluster.sh | 47 ++++++++++++++++++++ .github/workflows/integration.yml | 70 ++++++++++-------------------- .github/workflows/reusable.yml | 56 ++++++++++++++++++++++++ 7 files changed, 172 insertions(+), 48 deletions(-) create mode 100644 .github/docker-compose.yml create mode 100644 .github/dockers/Dockerfile.cluster create mode 100644 .github/dockers/cluster.redis.conf create mode 100644 .github/dockers/create_cluster.sh create mode 100644 .github/workflows/reusable.yml diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2af542a2..b7a2e345 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0-RC3 + image: redis/redis-stack-server:7.2.0 restart: unless-stopped networks: - redis diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml new file mode 100644 index 00000000..716aab4e --- /dev/null +++ b/.github/docker-compose.yml @@ -0,0 +1,30 @@ +--- +version: "3.8" +services: + + redis-stack-7.2.0: + image: redis/redis-stack-server:7.2.0 + ports: ["6379:6379"] + + redis-stack-6.2.6: + image: redis/redis-stack-server:6.2.6-v9 + ports: ["6379:6379"] + + redis-stack-edge: + image: redis/redis-stack-server:edge + ports: ["6379:6379"] + + redis-stack-cluster: + container_name: redis-cluster + build: + context: . + dockerfile: dockers/Dockerfile.cluster + ports: + - 16379:16379 + - 16380:16380 + - 16381:16381 + - 16382:16382 + - 16383:16383 + - 16384:16384 + volumes: + - "./dockers/cluster.redis.conf:/redis.conf:ro" \ No newline at end of file diff --git a/.github/dockers/Dockerfile.cluster b/.github/dockers/Dockerfile.cluster new file mode 100644 index 00000000..3a0d7341 --- /dev/null +++ b/.github/dockers/Dockerfile.cluster @@ -0,0 +1,7 @@ +FROM redis/redis-stack-server:edge as rss + +COPY dockers/create_cluster.sh /create_cluster.sh +RUN ls -R /opt/redis-stack +RUN chmod a+x /create_cluster.sh + +ENTRYPOINT [ "/create_cluster.sh"] diff --git a/.github/dockers/cluster.redis.conf b/.github/dockers/cluster.redis.conf new file mode 100644 index 00000000..d4de46fb --- /dev/null +++ b/.github/dockers/cluster.redis.conf @@ -0,0 +1,8 @@ +protected-mode no +enable-debug-command yes +loadmodule /opt/redis-stack/lib/redisearch.so +loadmodule /opt/redis-stack/lib/redisgraph.so +loadmodule /opt/redis-stack/lib/redistimeseries.so +loadmodule /opt/redis-stack/lib/rejson.so +loadmodule /opt/redis-stack/lib/redisbloom.so +loadmodule /opt/redis-stack/lib/redisgears.so v8-plugin-path /opt/redis-stack/lib/libredisgears_v8_plugin.so diff --git a/.github/dockers/create_cluster.sh b/.github/dockers/create_cluster.sh new file mode 100644 index 00000000..da9a0cb6 --- /dev/null +++ b/.github/dockers/create_cluster.sh @@ -0,0 +1,47 @@ +#! /bin/bash + +mkdir -p /nodes +touch /nodes/nodemap +if [ -z ${START_PORT} ]; then + START_PORT=16379 +fi +if [ -z ${END_PORT} ]; then + END_PORT=16384 +fi +if [ ! -z "$3" ]; then + START_PORT=$2 + START_PORT=$3 +fi +echo "STARTING: ${START_PORT}" +echo "ENDING: ${END_PORT}" + +for PORT in `seq ${START_PORT} ${END_PORT}`; do + mkdir -p /nodes/$PORT + if [[ -e /redis.conf ]]; then + cp /redis.conf /nodes/$PORT/redis.conf + else + touch /nodes/$PORT/redis.conf + fi + cat << EOF >> /nodes/$PORT/redis.conf +port ${PORT} +cluster-enabled yes +daemonize yes +logfile /redis.log +dir /nodes/$PORT +EOF + + set -x + /opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf + sleep 1 + if [ $? -ne 0 ]; then + echo "Redis failed to start, exiting." + continue + fi + echo 127.0.0.1:$PORT >> /nodes/nodemap +done +if [ -z "${REDIS_PASSWORD}" ]; then + echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 +else + echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 +fi +tail -f /redis.log diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 02e9f818..7df938a8 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,61 +12,37 @@ on: - cron: "0 1 * * *" jobs: - build_and_Test: - name: Test [redis-stack ${{matrix.redis-stack-version}}] - runs-on: ubuntu-latest + dotnet_6: + uses: ./.github/workflows/reusable.yml strategy: fail-fast: false + max-parallel: 5 matrix: - redis-stack-version: ["6.2.6-v9", "7.2.0-RC3", "edge"] - env: - USER_NAME: ${{ secrets.USER_NAME }} - PASSWORD: ${{ secrets.PASSWORD }} - ENDPOINT: ${{ secrets.ENDPOINT }} - REDIS_VERSION: ${{ matrix.redis-stack-version }} - steps: - - uses: actions/checkout@v3 - - name: .NET Core 6 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '6.0.x' - - name: .NET Core 7 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '7.0.x' - - name: run redis-stack-server docker - run: docker run -p 6379:6379 -d redis/redis-stack-server:${{matrix.redis-stack-version}} - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - - name: Test - run: | - echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_ca.pem - echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user.crt - echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user_private.key - ls -R - dotnet test -f net6.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - - name: Test - run: | - echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net7.0/redis_ca.pem - echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net7.0/redis_user.crt - echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net7.0/redis_user_private.key - ls -R - dotnet test -f net7.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - - name: Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{secrets.CODECOV_TOKEN}} - verbose: true - - name: Build - run: dotnet pack -c Release + redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + with: + redis_stack_type: ${{matrix.redis-stack-type}} + dotnet_version: 6.0.x + clr_version: net6.0 + secrets: inherit + + dotnet_7: + uses: ./.github/workflows/reusable.yml + strategy: + fail-fast: false + max-parallel: 5 + matrix: + redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + with: + redis_stack_type: ${{matrix.redis-stack-type}} + dotnet_version: 7.0.x + clr_version: net7.0 + secrets: inherit build_and_test_windows: name: Windows Test ${{matrix.redis-stack-version}} runs-on: windows-latest env: - redis_stack_version: 6.2.6-v7 + redis_stack_version: 6.2.6-v9 USER_NAME: ${{ secrets.USER_NAME }} PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml new file mode 100644 index 00000000..5e9c8b1f --- /dev/null +++ b/.github/workflows/reusable.yml @@ -0,0 +1,56 @@ +name: Build and Test +on: + workflow_call: + inputs: + + redis_stack_type: + required: true + type: string + + + dotnet_version: + required: true + type: string + + clr_version: + required: true + type: string + +jobs: + + build_and_Test: + name: Test [redis-stack ${{inputs.redis_stack_type}}] + runs-on: ubuntu-latest + + env: + USER_NAME: ${{ secrets.USER_NAME }} + PASSWORD: ${{ secrets.PASSWORD }} + ENDPOINT: ${{ secrets.ENDPOINT }} + steps: + - uses: actions/checkout@v3 + - name: .NET Core ${{inputs.dotnet_version}} + uses: actions/setup-dotnet@v2 + with: + dotnet-version: ${{inputs.dotnet_version}} + + - name: run redis-stack-server docker + run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true + - name: Test + run: | + echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_ca.pem + echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user.crt + echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net6.0/redis_user_private.key + ls -R + dotnet test -f ${{inputs.clr_version}} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover + - name: Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{secrets.CODECOV_TOKEN}} + verbose: true + - name: Build + run: dotnet pack -c Release + From d87cec041404f1807a7a67f46d39ee4096739071 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 14:20:02 +0300 Subject: [PATCH 17/48] wip --- .github/cluster.env | 2 ++ .github/standalone.env | 1 + .github/workflows/integration.yml | 31 ++++++++++++++++++++++++++++--- .github/workflows/reusable.yml | 13 ++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 .github/cluster.env create mode 100644 .github/standalone.env diff --git a/.github/cluster.env b/.github/cluster.env new file mode 100644 index 00000000..0d2a2906 --- /dev/null +++ b/.github/cluster.env @@ -0,0 +1,2 @@ +REDIS_CLUSTER=127.0.0.1:16379 +NUM_REDIS_CLUSTER_NODES=6 \ No newline at end of file diff --git a/.github/standalone.env b/.github/standalone.env new file mode 100644 index 00000000..e0cfd098 --- /dev/null +++ b/.github/standalone.env @@ -0,0 +1 @@ +REDIS=localhost:6379 \ No newline at end of file diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7df938a8..d795924f 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,17 +12,37 @@ on: - cron: "0 1 * * *" jobs: + dotnet_6_cluster: + uses: ./.github/workflows/reusable.yml + with: + redis_stack_type: cluster + dotnet_version: 6.0.x + clr_version: net6.0 + dotenv_file: .github/cluster.env + secrets: inherit + dotnet_6: uses: ./.github/workflows/reusable.yml strategy: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x clr_version: net6.0 + dotenv_file: .github/standalone.env + secrets: inherit + + dotnet_7_cluster: + uses: ./.github/workflows/reusable.yml + + with: + redis_stack_type: cluster + dotnet_version: 7.0.x + clr_version: net7.0 + dotenv_file: .github/cluster.env secrets: inherit dotnet_7: @@ -31,18 +51,23 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', 'cluster', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x clr_version: net7.0 + dotenv_file: .github/standalone.env secrets: inherit build_and_test_windows: name: Windows Test ${{matrix.redis-stack-version}} runs-on: windows-latest + strategy: + fail-fast: false + matrix: + redis-stack-version: ['6.2.9-v9', '7.2.0'] env: - redis_stack_version: 6.2.6-v9 + redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 5e9c8b1f..de992873 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -16,9 +16,12 @@ on: required: true type: string + dotenv_file: + required: true + type: string jobs: - build_and_Test: + build_and_test: name: Test [redis-stack ${{inputs.redis_stack_type}}] runs-on: ubuntu-latest @@ -27,14 +30,22 @@ jobs: PASSWORD: ${{ secrets.PASSWORD }} ENDPOINT: ${{ secrets.ENDPOINT }} steps: + - uses: actions/checkout@v3 + - name: .NET Core ${{inputs.dotnet_version}} uses: actions/setup-dotnet@v2 with: dotnet-version: ${{inputs.dotnet_version}} - name: run redis-stack-server docker + working-directory: ./github run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d + - name: set variables in dotenv + uses: c-py/action-dotenv-to-setenv@v2 + with: + env-file: ${{inputs.dotenv_file}} + - name: Restore dependencies run: dotnet restore - name: Build From b933427b797a32124e9893274770a672995483a3 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 14:22:16 +0300 Subject: [PATCH 18/48] fix / --- .github/workflows/reusable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index de992873..fb8570ca 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -39,7 +39,7 @@ jobs: dotnet-version: ${{inputs.dotnet_version}} - name: run redis-stack-server docker - working-directory: ./github + working-directory: .github run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d - name: set variables in dotenv uses: c-py/action-dotenv-to-setenv@v2 From ccb7625009393391e2b1ed70a1d7a03debbab091 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 14:24:36 +0300 Subject: [PATCH 19/48] -d --- .github/workflows/reusable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index fb8570ca..848b1728 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -40,7 +40,7 @@ jobs: - name: run redis-stack-server docker working-directory: .github - run: docker-compose up redis-stack-${{inputs.redis_stack_type}} -d + run: docker-compose up -d redis-stack-${{inputs.redis_stack_type}} - name: set variables in dotenv uses: c-py/action-dotenv-to-setenv@v2 with: From 908699d6fa384b00b24056332225776cc0b97705 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 15:47:28 +0300 Subject: [PATCH 20/48] delete restore --- .github/workflows/reusable.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 848b1728..28d14165 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -41,13 +41,12 @@ jobs: - name: run redis-stack-server docker working-directory: .github run: docker-compose up -d redis-stack-${{inputs.redis_stack_type}} + - name: set variables in dotenv uses: c-py/action-dotenv-to-setenv@v2 with: env-file: ${{inputs.dotenv_file}} - - name: Restore dependencies - run: dotnet restore - name: Build run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - name: Test From b5318bf3db7f8ecb60f32c7dd5a12a4a57d314bb Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 28 Aug 2023 15:57:00 +0300 Subject: [PATCH 21/48] return restore --- .github/workflows/reusable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 28d14165..dfb754c8 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -47,6 +47,8 @@ jobs: with: env-file: ${{inputs.dotenv_file}} + - name: Restore dependencies + run: dotnet restore - name: Build run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - name: Test From 31bef695faf1933741f66eebb04c18952e700b03 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 30 Aug 2023 17:24:20 +0300 Subject: [PATCH 22/48] add -RC3 --- .devcontainer/docker-compose.yml | 2 +- .github/docker-compose.yml | 2 +- .github/workflows/integration.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index b7a2e345..2af542a2 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0 + image: redis/redis-stack-server:7.2.0-RC3 restart: unless-stopped networks: - redis diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index 716aab4e..b9484c9f 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -3,7 +3,7 @@ version: "3.8" services: redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0 + image: redis/redis-stack-server:7.2.0-RC3 ports: ["6379:6379"] redis-stack-6.2.6: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d795924f..fc2d7634 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x @@ -51,7 +51,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x @@ -65,7 +65,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.9-v9', '7.2.0'] + redis-stack-version: ['6.2.9-v9', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From e544fe055c95dc822311711694d1d2e8dfa63b68 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 30 Aug 2023 17:26:19 +0300 Subject: [PATCH 23/48] add RC3 to docker-compose --- .github/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index b9484c9f..d56217a5 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: - redis-stack-7.2.0: + redis-stack-7.2.0-RC3: image: redis/redis-stack-server:7.2.0-RC3 ports: ["6379:6379"] From 5f67f42725c5b250f045ac40a7470d25d889b315 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 30 Aug 2023 17:53:08 +0300 Subject: [PATCH 24/48] try define both .net 6 and 7 --- .github/workflows/reusable.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index dfb754c8..e75d7025 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -33,10 +33,15 @@ jobs: - uses: actions/checkout@v3 - - name: .NET Core ${{inputs.dotnet_version}} + - name: .NET Core 6 uses: actions/setup-dotnet@v2 with: - dotnet-version: ${{inputs.dotnet_version}} + dotnet-version: '6.0.x' + + - name: .NET Core 7 + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '7.0.x' - name: run redis-stack-server docker working-directory: .github From 9724f9b17619b84026aba4adf703460a5371012e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 09:50:51 +0300 Subject: [PATCH 25/48] Skip if cluster where needed --- .github/workflows/reusable.yml | 1 - tests/Doc/Doc.csproj | 1 + tests/Doc/HashExample.cs | 3 ++- tests/Doc/SearchQuickstartExample.cs | 7 ++++--- tests/Doc/SetGetExample.cs | 5 +++-- tests/NRedisStack.Tests/PipelineTests.cs | 2 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 6 +++--- tests/NRedisStack.Tests/SkipIfRedisAttribute.cs | 4 +--- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index e75d7025..336ef9ae 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -7,7 +7,6 @@ on: required: true type: string - dotnet_version: required: true type: string diff --git a/tests/Doc/Doc.csproj b/tests/Doc/Doc.csproj index 56fdeec0..0958f541 100644 --- a/tests/Doc/Doc.csproj +++ b/tests/Doc/Doc.csproj @@ -20,5 +20,6 @@ + \ No newline at end of file diff --git a/tests/Doc/HashExample.cs b/tests/Doc/HashExample.cs index 913d3a0a..8212c722 100644 --- a/tests/Doc/HashExample.cs +++ b/tests/Doc/HashExample.cs @@ -1,5 +1,6 @@ // EXAMPLE: hash_tutorial // HIDE_START +using NRedisStack.Tests; using StackExchange.Redis; //REMOVE_START @@ -8,7 +9,7 @@ namespace NRedisStack.Doc; //REMOVE_END public class HashExample { - [Fact] + [SkipIfRedis(Is.Cluster)] public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/SearchQuickstartExample.cs b/tests/Doc/SearchQuickstartExample.cs index 142ab1b1..d8643356 100644 --- a/tests/Doc/SearchQuickstartExample.cs +++ b/tests/Doc/SearchQuickstartExample.cs @@ -3,6 +3,7 @@ using NRedisStack.Search; using NRedisStack.Search.Aggregation; using NRedisStack.Search.Literals.Enums; +using NRedisStack.Tests; using StackExchange.Redis; // REMOVE_START @@ -11,7 +12,7 @@ namespace NRedisStack.Doc; // REMOVE_END public class SearchQuickstartExample { - [Fact] + [SkipIfRedis(Is.Cluster)] public void run() { // STEP_START connect @@ -21,7 +22,7 @@ public void run() var json = db.JSON(); // STEP_END - // REMOVE_START + // REMOVE_START try { ft.DropIndex("idx:bicycle"); @@ -41,7 +42,7 @@ public void run() "for the smallest of tikes! This is the tiniest " + "kids’ pedal bike on the market available without" + " a coaster brake, the Jigger is the vehicle of " + - "choice for the rare tenacious little rider " + + "choice for the rare tenacious little rider " + "raring to go.", Condition = "used" }; diff --git a/tests/Doc/SetGetExample.cs b/tests/Doc/SetGetExample.cs index 6b381de0..805b8868 100644 --- a/tests/Doc/SetGetExample.cs +++ b/tests/Doc/SetGetExample.cs @@ -1,6 +1,7 @@ // EXAMPLE: set_and_get // HIDE_START using System; +using NRedisStack.Tests; using StackExchange.Redis; //REMOVE_START @@ -9,7 +10,7 @@ namespace NRedisStack.Doc; //REMOVE_END public class SetGetExample { - [Fact] + [SkipIfRedis(Is.Cluster)] public void run() { var redis = ConnectionMultiplexer.Connect("localhost:6379"); @@ -17,7 +18,7 @@ public void run() //HIDE_END bool status = db.StringSet("bike:1", "Process 134"); - + if (status) Console.WriteLine("Successfully added a bike."); diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 6279f7d8..41369e21 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -114,7 +114,7 @@ public async Task TestModulsPipelineWithotGraph() Assert.NotNull(db.TOPK().Info("topk-key")); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestBloomPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index fca6b388..9946db30 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -839,7 +839,7 @@ public async Task AlterAddAsync() Assert.Equal(4, info.CursorStats.Count); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void TestConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -850,7 +850,7 @@ public void TestConfig() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task TestConfigAsnyc() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -2755,7 +2755,7 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void Issue175() { ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs index 8b035f13..7853a3c3 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -1,8 +1,6 @@ using Xunit; -using StackExchange.Redis; -using NRedisStack.Tests; -using System.Text; +namespace NRedisStack.Tests; public enum Comparison { LessThan, From d998125562d65aa171a21a541aae95f7f5ec3f59 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 10:05:05 +0300 Subject: [PATCH 26/48] add names --- .github/workflows/integration.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index fc2d7634..ad214ea7 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -13,6 +13,7 @@ on: jobs: dotnet_6_cluster: + name: .NET 6 on Redis Cluster uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -22,6 +23,7 @@ jobs: secrets: inherit dotnet_6: + name: .NET 6 on Redis Standalone uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -36,8 +38,8 @@ jobs: secrets: inherit dotnet_7_cluster: + name: .NET 7 on Redis Cluster uses: ./.github/workflows/reusable.yml - with: redis_stack_type: cluster dotnet_version: 7.0.x @@ -46,6 +48,7 @@ jobs: secrets: inherit dotnet_7: + name: .NET 7 on Redis Standalone uses: ./.github/workflows/reusable.yml strategy: fail-fast: false From 2842a2984fb5540b53ae7af411bc18233f269248 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 10:05:18 +0300 Subject: [PATCH 27/48] skip configOnTimeout if cluster --- tests/NRedisStack.Tests/Search/SearchTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 9946db30..88669f9d 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -861,7 +861,7 @@ public async Task TestConfigAsnyc() Assert.Equal("100", configMap["TIMEOUT"].ToString()); } - [Fact] + [SkipIfRedis(Is.Cluster)] public void configOnTimeout() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -873,7 +873,7 @@ public void configOnTimeout() try { ft.ConfigSet("ON_TIMEOUT", "null"); } catch (RedisServerException) { } } - [Fact] + [SkipIfRedis(Is.Cluster)] public async Task configOnTimeoutAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); From d07f2251554cbb9dec0c50feffd2ddac85a31903 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 12:24:22 +0300 Subject: [PATCH 28/48] try to fix win tests --- .github/workflows/integration.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ad214ea7..d37bf14b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -13,7 +13,7 @@ on: jobs: dotnet_6_cluster: - name: .NET 6 on Redis Cluster + name: .NET 6 uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -23,7 +23,7 @@ jobs: secrets: inherit dotnet_6: - name: .NET 6 on Redis Standalone + name: .NET 6 uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -38,7 +38,7 @@ jobs: secrets: inherit dotnet_7_cluster: - name: .NET 7 on Redis Cluster + name: .NET 7 uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -48,7 +48,7 @@ jobs: secrets: inherit dotnet_7: - name: .NET 7 on Redis Standalone + name: .NET 7 uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.9-v9', '7.2.0-RC3'] + redis-stack-version: ['6.2.9-v7', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From 661cb1c1aa2d4b535564bb5c08e17c8d7e30a34c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 12:55:15 +0300 Subject: [PATCH 29/48] tests names +fix win version --- .github/workflows/integration.yml | 10 +++++----- .github/workflows/reusable.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d37bf14b..0e091537 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -13,7 +13,7 @@ on: jobs: dotnet_6_cluster: - name: .NET 6 + name: .NET 6 on [redis-stack cluster] uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -23,7 +23,7 @@ jobs: secrets: inherit dotnet_6: - name: .NET 6 + name: .NET 6 on [redis-stack ${{matrix.redis-stack-type}}] uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -38,7 +38,7 @@ jobs: secrets: inherit dotnet_7_cluster: - name: .NET 7 + name: .NET 7 on [redis-stack cluster] uses: ./.github/workflows/reusable.yml with: redis_stack_type: cluster @@ -48,7 +48,7 @@ jobs: secrets: inherit dotnet_7: - name: .NET 7 + name: .NET 7 on standalone [redis-stack ${{matrix.redis-stack-type}}] uses: ./.github/workflows/reusable.yml strategy: fail-fast: false @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.9-v7', '7.2.0-RC3'] + redis-stack-version: ['6.2.13', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} diff --git a/.github/workflows/reusable.yml b/.github/workflows/reusable.yml index 336ef9ae..0d1a63ac 100644 --- a/.github/workflows/reusable.yml +++ b/.github/workflows/reusable.yml @@ -21,7 +21,7 @@ on: jobs: build_and_test: - name: Test [redis-stack ${{inputs.redis_stack_type}}] + name: Test runs-on: ubuntu-latest env: From b4a5ff2870486af1fa93882055a5c742ae7c791e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 13:17:42 +0300 Subject: [PATCH 30/48] fix versions --- .devcontainer/docker-compose.yml | 2 +- .github/workflows/integration.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2af542a2..d1aed936 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0-RC3 + image: redis/redis-stack-server:7.2.0-v0 restart: unless-stopped networks: - redis diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0e091537..d50630f9 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -29,7 +29,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] + redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x @@ -48,13 +48,13 @@ jobs: secrets: inherit dotnet_7: - name: .NET 7 on standalone [redis-stack ${{matrix.redis-stack-type}}] + name: .NET 7 on [redis-stack ${{matrix.redis-stack-type}}] uses: ./.github/workflows/reusable.yml strategy: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] + redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.13', '7.2.0-RC3'] + redis-stack-version: ['6.2.6-v9', '7.2.0-v0'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From 6c98a16bb69ce0201f7a53bcd5800a2c34e941ad Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 13:26:10 +0300 Subject: [PATCH 31/48] versions --- .devcontainer/docker-compose.yml | 2 +- .github/workflows/integration.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index d1aed936..2af542a2 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -17,7 +17,7 @@ services: REDIS__edge: "redis-stack-edge:6379" redis-stack-7.2.0: - image: redis/redis-stack-server:7.2.0-v0 + image: redis/redis-stack-server:7.2.0-RC3 restart: unless-stopped networks: - redis diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d50630f9..8804a118 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -29,7 +29,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 6.0.x @@ -54,7 +54,7 @@ jobs: fail-fast: false max-parallel: 5 matrix: - redis-stack-type: ['edge', '6.2.6-v9', '7.2.0-v0'] + redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] with: redis_stack_type: ${{matrix.redis-stack-type}} dotnet_version: 7.0.x @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.6-v9', '7.2.0-v0'] + redis-stack-version: ['6.2.6', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From b1feed4db47933487d40505d80500e63e72bb67a Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 13:30:33 +0300 Subject: [PATCH 32/48] win verer --- .github/workflows/integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 8804a118..c715948c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -68,7 +68,7 @@ jobs: strategy: fail-fast: false matrix: - redis-stack-version: ['6.2.6', '7.2.0-RC3'] + redis-stack-version: ['6.2.6-v9', '7.2.0-RC3'] env: redis_stack_version: ${{matrix.redis-stack-version}} USER_NAME: ${{ secrets.USER_NAME }} From 3b79773805ee58a5ea64735a791a826affdf0487 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Thu, 31 Aug 2023 15:40:11 +0300 Subject: [PATCH 33/48] wording --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8dc83bd9..9eaade76 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ e.g: dotnet test --environment="REDIS=172.17.0.1:6379" ``` -If you want to run your tests against an oss cluster, you can do it thus: +To run your tests against an oss cluster: ```bash dotnet test --environment "REDIS_CLUSTER=" --environment "NUM_REDIS_CLUSTER_NODES=" ``` From bff96ca157e0d1302e26c27543e92da73a2643e4 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Sun, 10 Sep 2023 15:02:16 +0300 Subject: [PATCH 34/48] dotnet format --- .../CuckooFilter/ICuckooCommands.cs | 2 +- .../CuckooFilter/ICuckooCommandsAsync.cs | 2 +- .../CuckooFilter/Literals/CommandArgs.cs | 12 +- src/NRedisStack/Gears/GearsCommandBuilder.cs | 2 +- src/NRedisStack/Gears/GearsCommands.cs | 4 +- src/NRedisStack/Gears/GearsCommandsAsync.cs | 4 +- src/NRedisStack/Graph/DataTypes/Node.cs | 2 +- src/NRedisStack/Graph/DataTypes/Path.cs | 4 +- src/NRedisStack/Graph/RedisGraphUtilities.cs | 4 +- src/NRedisStack/Graph/ResultSet.cs | 2 +- src/NRedisStack/Graph/Statistics.cs | 40 ++--- src/NRedisStack/Json/JsonCommandBuilder.cs | 4 +- src/NRedisStack/Json/JsonCommandsAsync.cs | 4 +- src/NRedisStack/ResponseParser.cs | 6 +- src/NRedisStack/Search/AggregationRequest.cs | 4 +- src/NRedisStack/Search/Document.cs | 8 +- src/NRedisStack/Search/FTSpellCheckParams.cs | 12 +- src/NRedisStack/Search/Limit.cs | 16 +- src/NRedisStack/Search/Query.cs | 2 +- .../Search/SearchCommandBuilder.cs | 10 +- src/NRedisStack/Search/SearchCommands.cs | 4 +- src/NRedisStack/Search/SearchResult.cs | 2 +- src/NRedisStack/Tdigest/TdigestCommands.cs | 2 +- .../DataTypes/TimeSeriesInformation.cs | 6 +- src/NRedisStack/TopK/TopKCommandBuilder.cs | 2 +- src/NRedisStack/TopK/TopKCommands.cs | 2 +- src/NRedisStack/TopK/TopKCommandsAsync.cs | 2 +- src/NRedisStack/Transactions.cs | 4 +- tests/Doc/HashExample.cs | 2 +- tests/Doc/SearchQuickstartExample.cs | 2 +- tests/Doc/SetGetExample.cs | 2 +- .../CuckooFilter/CuckooTests.cs | 16 +- tests/NRedisStack.Tests/Graph/GraphTests.cs | 28 ++-- .../Graph/Utils/PathBuilderTest.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 8 +- tests/NRedisStack.Tests/PipelineTests.cs | 10 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 158 ++++++++---------- .../TimeSeries/TestAPI/TestAlter.cs | 4 +- .../TimeSeries/TestAPI/TestAlterAsync.cs | 4 +- .../TestTimeSeriesInformation.cs | 12 +- tests/NRedisStack.Tests/TopK/TopKTests.cs | 38 ++--- tests/NRedisStack.Tests/TransactionsTests.cs | 4 +- 42 files changed, 225 insertions(+), 233 deletions(-) diff --git a/src/NRedisStack/CuckooFilter/ICuckooCommands.cs b/src/NRedisStack/CuckooFilter/ICuckooCommands.cs index 18852203..4483f1c0 100644 --- a/src/NRedisStack/CuckooFilter/ICuckooCommands.cs +++ b/src/NRedisStack/CuckooFilter/ICuckooCommands.cs @@ -124,6 +124,6 @@ bool Reserve(RedisKey key, long capacity, /// Iterator value; either 0 or the iterator from a previous invocation of this command. /// Tuple of iterator and data. /// - Tuple ScanDump(RedisKey key, long iterator); + Tuple ScanDump(RedisKey key, long iterator); } } \ No newline at end of file diff --git a/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs b/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs index acf67b69..6717c02a 100644 --- a/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs +++ b/src/NRedisStack/CuckooFilter/ICuckooCommandsAsync.cs @@ -124,6 +124,6 @@ Task ReserveAsync(RedisKey key, long capacity, /// Iterator value; either 0 or the iterator from a previous invocation of this command. /// Tuple of iterator and data. /// - Task> ScanDumpAsync(RedisKey key, long iterator); + Task> ScanDumpAsync(RedisKey key, long iterator); } } \ No newline at end of file diff --git a/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs b/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs index 3b6b6c16..b480700b 100644 --- a/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs +++ b/src/NRedisStack/CuckooFilter/Literals/CommandArgs.cs @@ -2,11 +2,11 @@ namespace NRedisStack.CuckooFilter.Literals { internal class CuckooArgs { - public const string CAPACITY = "CAPACITY"; - public const string EXPANSION = "EXPANSION"; - public const string NOCREATE = "NOCREATE"; - public const string ITEMS = "ITEMS"; - public const string BUCKETSIZE = "BUCKETSIZE"; - public const string MAXITERATIONS = "MAXITERATIONS"; + public const string CAPACITY = "CAPACITY"; + public const string EXPANSION = "EXPANSION"; + public const string NOCREATE = "NOCREATE"; + public const string ITEMS = "ITEMS"; + public const string BUCKETSIZE = "BUCKETSIZE"; + public const string MAXITERATIONS = "MAXITERATIONS"; } } \ No newline at end of file diff --git a/src/NRedisStack/Gears/GearsCommandBuilder.cs b/src/NRedisStack/Gears/GearsCommandBuilder.cs index 31d8c73c..5af745ba 100644 --- a/src/NRedisStack/Gears/GearsCommandBuilder.cs +++ b/src/NRedisStack/Gears/GearsCommandBuilder.cs @@ -58,7 +58,7 @@ public static SerializedCommand TFunctionList(bool withCode = false, int verbose public static SerializedCommand TFCall(string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false) { string command = async ? RG.TFCALLASYNC : RG.TFCALL; - var commandArgs = new List() {$"{libraryName}.{functionName}"}; + var commandArgs = new List() { $"{libraryName}.{functionName}" }; if (keys != null) { diff --git a/src/NRedisStack/Gears/GearsCommands.cs b/src/NRedisStack/Gears/GearsCommands.cs index 2eb885f0..64b7eeb8 100644 --- a/src/NRedisStack/Gears/GearsCommands.cs +++ b/src/NRedisStack/Gears/GearsCommands.cs @@ -58,7 +58,7 @@ public static Dictionary[] TFunctionList(this IDatabase db, /// public static RedisResult TFCall_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false)); + return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: false)); } /// @@ -72,7 +72,7 @@ public static RedisResult TFCall_(this IDatabase db, string libraryName, string /// public static RedisResult TFCallAsync_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true)); + return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: true)); } } } diff --git a/src/NRedisStack/Gears/GearsCommandsAsync.cs b/src/NRedisStack/Gears/GearsCommandsAsync.cs index 4842a3ed..09b1fafa 100644 --- a/src/NRedisStack/Gears/GearsCommandsAsync.cs +++ b/src/NRedisStack/Gears/GearsCommandsAsync.cs @@ -57,7 +57,7 @@ public static async Task[]> TFunctionListAsync(t /// public async static Task TFCall_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false)); + return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: false)); } /// @@ -71,7 +71,7 @@ public async static Task TFCall_Async(this IDatabase db, string lib /// public async static Task TFCallAsync_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null) { - return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true)); + return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async: true)); } } } diff --git a/src/NRedisStack/Graph/DataTypes/Node.cs b/src/NRedisStack/Graph/DataTypes/Node.cs index dae07ef1..960ac145 100644 --- a/src/NRedisStack/Graph/DataTypes/Node.cs +++ b/src/NRedisStack/Graph/DataTypes/Node.cs @@ -53,7 +53,7 @@ public override int GetHashCode() { int hash = 17; - foreach(var label in Labels) + foreach (var label in Labels) { hash = hash * 31 + label.GetHashCode(); } diff --git a/src/NRedisStack/Graph/DataTypes/Path.cs b/src/NRedisStack/Graph/DataTypes/Path.cs index 02af0c8e..62a3552c 100644 --- a/src/NRedisStack/Graph/DataTypes/Path.cs +++ b/src/NRedisStack/Graph/DataTypes/Path.cs @@ -11,8 +11,8 @@ namespace NRedisStack.Graph.DataTypes /// public class Path { - public ReadOnlyCollection Nodes { get;} - public ReadOnlyCollection Edges { get;} + public ReadOnlyCollection Nodes { get; } + public ReadOnlyCollection Edges { get; } public Path(IList nodes, IList edges) { diff --git a/src/NRedisStack/Graph/RedisGraphUtilities.cs b/src/NRedisStack/Graph/RedisGraphUtilities.cs index b0eae675..b8bac43e 100644 --- a/src/NRedisStack/Graph/RedisGraphUtilities.cs +++ b/src/NRedisStack/Graph/RedisGraphUtilities.cs @@ -60,7 +60,7 @@ public static string ValueToString(object value) foreach (var val in valueList) { - objectValueList.Add((object) val); + objectValueList.Add((object)val); } return ArrayToString(objectValueList.ToArray()); @@ -90,7 +90,7 @@ private static string ArrayToString(object[] array) { if (x.GetType().IsArray) { - return ArrayToString((object[]) x); + return ArrayToString((object[])x); } else { diff --git a/src/NRedisStack/Graph/ResultSet.cs b/src/NRedisStack/Graph/ResultSet.cs index 334f0a8a..88618fcb 100644 --- a/src/NRedisStack/Graph/ResultSet.cs +++ b/src/NRedisStack/Graph/ResultSet.cs @@ -255,7 +255,7 @@ private Dictionary DeserializeDictionary(RedisResult rawPath) for (int i = 0; i < size; i += 2) { string key = keyTypeValueEntries[i].ToString(); - object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i+1]); + object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i + 1]); dict.Add(key, value); } return dict; diff --git a/src/NRedisStack/Graph/Statistics.cs b/src/NRedisStack/Graph/Statistics.cs index 0991998c..66a5db99 100644 --- a/src/NRedisStack/Graph/Statistics.cs +++ b/src/NRedisStack/Graph/Statistics.cs @@ -11,28 +11,28 @@ internal Statistics(Dictionary statistics) { _statistics = statistics; - NodesCreated = GetIntValue("Nodes created"); - NodesDeleted = GetIntValue("Nodes deleted"); - IndicesAdded = GetIntValue("Indices added"); - IndicesCreated = GetIntValue("Indices created"); - IndicesDeleted = GetIntValue("Indices deleted"); - LabelsAdded = GetIntValue("Labels added"); - RelationshipsDeleted = GetIntValue("Relationships deleted"); - RelationshipsCreated = GetIntValue("Relationships created"); - PropertiesSet = GetIntValue("Properties set"); - QueryInternalExecutionTime = GetStringValue("Query internal execution time"); - GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time"); - CachedExecution = (GetIntValue("Cached execution") == 1); + NodesCreated = GetIntValue("Nodes created"); + NodesDeleted = GetIntValue("Nodes deleted"); + IndicesAdded = GetIntValue("Indices added"); + IndicesCreated = GetIntValue("Indices created"); + IndicesDeleted = GetIntValue("Indices deleted"); + LabelsAdded = GetIntValue("Labels added"); + RelationshipsDeleted = GetIntValue("Relationships deleted"); + RelationshipsCreated = GetIntValue("Relationships created"); + PropertiesSet = GetIntValue("Properties set"); + QueryInternalExecutionTime = GetStringValue("Query internal execution time"); + GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time"); + CachedExecution = (GetIntValue("Cached execution") == 1); - } + } - /// - /// Retrieves the relevant statistic. - /// - /// The requested statistic label. - /// A string representation of the specific statistic or null - public string? GetStringValue(string label) => - _statistics.TryGetValue(label, out string? value) ? value : null; + /// + /// Retrieves the relevant statistic. + /// + /// The requested statistic label. + /// A string representation of the specific statistic or null + public string? GetStringValue(string label) => + _statistics.TryGetValue(label, out string? value) ? value : null; private int GetIntValue(string label) diff --git a/src/NRedisStack/Json/JsonCommandBuilder.cs b/src/NRedisStack/Json/JsonCommandBuilder.cs index b5505100..d5846a8a 100644 --- a/src/NRedisStack/Json/JsonCommandBuilder.cs +++ b/src/NRedisStack/Json/JsonCommandBuilder.cs @@ -34,8 +34,8 @@ public static SerializedCommand MSet(KeyPathValue[] KeyPathValueList) if (KeyPathValueList.Length < 1) throw new ArgumentOutOfRangeException(nameof(KeyPathValueList)); - var args = KeyPathValueList.SelectMany(x => x.ToArray()).ToArray(); - return new SerializedCommand(JSON.MSET, args); + var args = KeyPathValueList.SelectMany(x => x.ToArray()).ToArray(); + return new SerializedCommand(JSON.MSET, args); } public static SerializedCommand Merge(RedisKey key, RedisValue path, RedisValue json) diff --git a/src/NRedisStack/Json/JsonCommandsAsync.cs b/src/NRedisStack/Json/JsonCommandsAsync.cs index c42fcbd5..2623b1b2 100644 --- a/src/NRedisStack/Json/JsonCommandsAsync.cs +++ b/src/NRedisStack/Json/JsonCommandsAsync.cs @@ -169,7 +169,7 @@ public async Task SetFromFileAsync(RedisKey key, RedisValue path, string f throw new FileNotFoundException($"File {filePath} not found."); } - string fileContent = File.ReadAllText(filePath); + string fileContent = File.ReadAllText(filePath); return await SetAsync(key, path, fileContent, when); } @@ -181,7 +181,7 @@ public async Task SetFromDirectoryAsync(RedisValue path, string filesPath, foreach (var filePath in files) { key = filePath.Substring(0, filePath.IndexOf(".")); - if(await SetFromFileAsync(key, path, filePath, when)) + if (await SetFromFileAsync(key, path, filePath, when)) { inserted++; } diff --git a/src/NRedisStack/ResponseParser.cs b/src/NRedisStack/ResponseParser.cs index 2865531e..ce04d2de 100644 --- a/src/NRedisStack/ResponseParser.cs +++ b/src/NRedisStack/ResponseParser.cs @@ -580,7 +580,7 @@ public static List ToStringList(this RedisResult result) return new[] { (long?)result }; } - return ((RedisResult[])result!).Select(x=>(long?)x).ToArray(); + return ((RedisResult[])result!).Select(x => (long?)x).ToArray(); } public static IEnumerable> ToHashSets(this RedisResult result) @@ -626,7 +626,7 @@ public static Dictionary> ToFtSpellCheckResul string termValue = rawElements[1].ToString()!; - var list = (RedisResult[]) rawElements[2]!; + var list = (RedisResult[])rawElements[2]!; Dictionary entries = new Dictionary(list.Length); foreach (var entry in list) { @@ -653,7 +653,7 @@ public static List> ToStringDoubleTupleList(this RedisResu } return list; } - + public static Dictionary ToStringRedisResultDictionary(this RedisResult value) { var res = (RedisResult[])value!; diff --git a/src/NRedisStack/Search/AggregationRequest.cs b/src/NRedisStack/Search/AggregationRequest.cs index e5854f99..29eee63c 100644 --- a/src/NRedisStack/Search/AggregationRequest.cs +++ b/src/NRedisStack/Search/AggregationRequest.cs @@ -39,7 +39,7 @@ public class AggregationRequest // Params: private Dictionary nameValue = new Dictionary(); - public int? dialect {get; private set;} = null; + public int? dialect { get; private set; } = null; public AggregationRequest(string query, int? defaultDialect = null) { @@ -57,7 +57,7 @@ public AggregationRequest Verbatim(bool verbatim = true) private void Verbatim() { - if(verbatim == true) + if (verbatim == true) args.Add("VERBATIM"); } diff --git a/src/NRedisStack/Search/Document.cs b/src/NRedisStack/Search/Document.cs index 7c61b1c1..3135621f 100644 --- a/src/NRedisStack/Search/Document.cs +++ b/src/NRedisStack/Search/Document.cs @@ -8,7 +8,7 @@ namespace NRedisStack.Search public class Document { public string Id { get; } - public double Score { get; set;} + public double Score { get; set; } public byte[] Payload { get; } public string[] ScoreExplained { get; private set; } // TODO: check if this is needed (Jedis does not have it) internal readonly Dictionary _properties; @@ -35,10 +35,12 @@ public static Document Load(string id, double score, byte[] payload, RedisValue[ for (int i = 0; i < fields.Length; i += 2) { string fieldName = (string)fields[i]; - if (fieldName == "$") { + if (fieldName == "$") + { ret["json"] = fields[i + 1]; } - else { + else + { ret[fieldName] = fields[i + 1]; } } diff --git a/src/NRedisStack/Search/FTSpellCheckParams.cs b/src/NRedisStack/Search/FTSpellCheckParams.cs index 97242604..74d3af86 100644 --- a/src/NRedisStack/Search/FTSpellCheckParams.cs +++ b/src/NRedisStack/Search/FTSpellCheckParams.cs @@ -76,12 +76,12 @@ private void Dialect() private void Terms() { - foreach (var term in terms) - { - args.Add(SearchArgs.TERMS); - args.Add(term.Value); - args.Add(term.Key); - } + foreach (var term in terms) + { + args.Add(SearchArgs.TERMS); + args.Add(term.Value); + args.Add(term.Key); + } } private void Distance() diff --git a/src/NRedisStack/Search/Limit.cs b/src/NRedisStack/Search/Limit.cs index 151cbeec..e3e9e917 100644 --- a/src/NRedisStack/Search/Limit.cs +++ b/src/NRedisStack/Search/Limit.cs @@ -11,14 +11,14 @@ public Limit(int offset, int count) _count = count; } -// public void addArgs(List args) { -// if (count == 0) { -// return; -// } -// args.add("LIMIT"); -// args.add(Integer.toString(offset)); -// args.add(Integer.toString(count)); -// } + // public void addArgs(List args) { + // if (count == 0) { + // return; + // } + // args.add("LIMIT"); + // args.add(Integer.toString(offset)); + // args.add(Integer.toString(count)); + // } internal void SerializeRedisArgs(List args) { diff --git a/src/NRedisStack/Search/Query.cs b/src/NRedisStack/Search/Query.cs index 4b2bad54..b75fd184 100644 --- a/src/NRedisStack/Search/Query.cs +++ b/src/NRedisStack/Search/Query.cs @@ -192,7 +192,7 @@ public HighlightTags(string open, string close) // public bool ExplainScore { get; set; } // TODO: Check if this is needed because Jedis doesn't have it private Dictionary _params = new Dictionary(); - public int? dialect { get; private set;} = null; + public int? dialect { get; private set; } = null; private int _slop = -1; private long _timeout = -1; private bool _inOrder = false; diff --git a/src/NRedisStack/Search/SearchCommandBuilder.cs b/src/NRedisStack/Search/SearchCommandBuilder.cs index 7da5b388..1d962a96 100644 --- a/src/NRedisStack/Search/SearchCommandBuilder.cs +++ b/src/NRedisStack/Search/SearchCommandBuilder.cs @@ -163,8 +163,8 @@ public static SerializedCommand ProfileSearch(string IndexName, Query q, bool li { var args = (limited) - ? new List(){IndexName, SearchArgs.SEARCH, SearchArgs.LIMITED, SearchArgs.QUERY} - : new List(){IndexName, SearchArgs.SEARCH, SearchArgs.QUERY}; + ? new List() { IndexName, SearchArgs.SEARCH, SearchArgs.LIMITED, SearchArgs.QUERY } + : new List() { IndexName, SearchArgs.SEARCH, SearchArgs.QUERY }; q.SerializeRedisArgs(args); return new SerializedCommand(FT.PROFILE, args); @@ -172,9 +172,9 @@ public static SerializedCommand ProfileSearch(string IndexName, Query q, bool li public static SerializedCommand ProfileAggregate(string IndexName, AggregationRequest query, bool limited = false) { - var args = (limited) - ? new List{IndexName, SearchArgs.AGGREGATE, SearchArgs.LIMITED, SearchArgs.QUERY} - : new List{IndexName, SearchArgs.AGGREGATE, SearchArgs.QUERY}; + var args = (limited) + ? new List { IndexName, SearchArgs.AGGREGATE, SearchArgs.LIMITED, SearchArgs.QUERY } + : new List { IndexName, SearchArgs.AGGREGATE, SearchArgs.QUERY }; query.SerializeRedisArgs(); args.AddRange(query.GetArgs()); diff --git a/src/NRedisStack/Search/SearchCommands.cs b/src/NRedisStack/Search/SearchCommands.cs index a53772d8..30a1e58d 100644 --- a/src/NRedisStack/Search/SearchCommands.cs +++ b/src/NRedisStack/Search/SearchCommands.cs @@ -16,7 +16,7 @@ public SearchCommands(IDatabase db, int? defaultDialect) : base(db) public void SetDefaultDialect(int? defaultDialect) { - if(defaultDialect == 0) + if (defaultDialect == 0) { throw new System.ArgumentOutOfRangeException("DIALECT=0 cannot be set."); } @@ -87,7 +87,7 @@ public bool Create(string indexName, FTCreateParams parameters, Schema schema) /// public bool Create(string indexName, Schema schema) { - return Create(indexName, new FTCreateParams(), schema); + return Create(indexName, new FTCreateParams(), schema); } /// diff --git a/src/NRedisStack/Search/SearchResult.cs b/src/NRedisStack/Search/SearchResult.cs index d111f6eb..d42bf33b 100644 --- a/src/NRedisStack/Search/SearchResult.cs +++ b/src/NRedisStack/Search/SearchResult.cs @@ -66,7 +66,7 @@ internal SearchResult(RedisResult[] resp, bool hasContent, bool hasScores, bool // } //else //{ - score = (double)resp[i + scoreOffset]; + score = (double)resp[i + scoreOffset]; //} } if (hasPayloads) diff --git a/src/NRedisStack/Tdigest/TdigestCommands.cs b/src/NRedisStack/Tdigest/TdigestCommands.cs index 72d5f847..fd11a3e8 100644 --- a/src/NRedisStack/Tdigest/TdigestCommands.cs +++ b/src/NRedisStack/Tdigest/TdigestCommands.cs @@ -45,7 +45,7 @@ public double Max(RedisKey key) public double Min(RedisKey key) { var cmd = TdigestCommandBuilder.Min(key); - var res =_db.Execute(cmd); + var res = _db.Execute(cmd); return res.ToDouble(); } diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs index e127ea44..e88de817 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs @@ -68,12 +68,12 @@ public class TimeSeriesInformation /// /// The policy will define handling of duplicate samples. /// - public TsDuplicatePolicy? DuplicatePolicy { get; private set; } + public TsDuplicatePolicy? DuplicatePolicy { get; private set; } /// /// In DEBUG mode: Key self name. /// - public string? KeySelfName { get; private set; } + public string? KeySelfName { get; private set; } /// /// In DEBUG mode: gives more information about the chunks @@ -95,7 +95,7 @@ internal TimeSeriesInformation(long totalSamples, long memoryUsage, SourceKey = sourceKey; Rules = rules; // backwards compatible with RedisTimeSeries < v1.4 - MaxSamplesPerChunk = chunkSize/16; + MaxSamplesPerChunk = chunkSize / 16; ChunkSize = chunkSize; // configure what to do on duplicate sample > v1.4 DuplicatePolicy = policy; diff --git a/src/NRedisStack/TopK/TopKCommandBuilder.cs b/src/NRedisStack/TopK/TopKCommandBuilder.cs index 2adf5fa7..fd697a1d 100644 --- a/src/NRedisStack/TopK/TopKCommandBuilder.cs +++ b/src/NRedisStack/TopK/TopKCommandBuilder.cs @@ -40,7 +40,7 @@ public static SerializedCommand IncrBy(RedisKey key, params Tuple public RedisResult[]? Add(RedisKey key, params RedisValue[] items) { - return (RedisResult[]?) _db.Execute(TopKCommandBuilder.Add(key, items)); + return (RedisResult[]?)_db.Execute(TopKCommandBuilder.Add(key, items)); } /// diff --git a/src/NRedisStack/TopK/TopKCommandsAsync.cs b/src/NRedisStack/TopK/TopKCommandsAsync.cs index 20576147..0fd9656a 100644 --- a/src/NRedisStack/TopK/TopKCommandsAsync.cs +++ b/src/NRedisStack/TopK/TopKCommandsAsync.cs @@ -14,7 +14,7 @@ public TopKCommandsAsync(IDatabaseAsync db) /// public async Task AddAsync(RedisKey key, params RedisValue[] items) { - return (RedisResult[]?) await _db.ExecuteAsync(TopKCommandBuilder.Add(key, items)); + return (RedisResult[]?)await _db.ExecuteAsync(TopKCommandBuilder.Add(key, items)); } /// diff --git a/src/NRedisStack/Transactions.cs b/src/NRedisStack/Transactions.cs index 2399090d..f260fe6d 100644 --- a/src/NRedisStack/Transactions.cs +++ b/src/NRedisStack/Transactions.cs @@ -12,9 +12,9 @@ public Transaction(IDatabase db) _transaction = db.CreateTransaction(); } - public ConditionResult AddCondition(Condition condition) => _transaction.AddCondition(condition); + public ConditionResult AddCondition(Condition condition) => _transaction.AddCondition(condition); - public bool Execute(CommandFlags flags = CommandFlags.None) => _transaction.Execute(flags); + public bool Execute(CommandFlags flags = CommandFlags.None) => _transaction.Execute(flags); public Task ExecuteAsync(CommandFlags flags = CommandFlags.None) => _transaction.ExecuteAsync(flags); diff --git a/tests/Doc/HashExample.cs b/tests/Doc/HashExample.cs index 8212c722..d50f868b 100644 --- a/tests/Doc/HashExample.cs +++ b/tests/Doc/HashExample.cs @@ -122,7 +122,7 @@ public void run() //REMOVE_END // Bike stats: crashes=1, owners=1 //STEP_END - //HIDE_START + //HIDE_START } } //HIDE_END \ No newline at end of file diff --git a/tests/Doc/SearchQuickstartExample.cs b/tests/Doc/SearchQuickstartExample.cs index d8643356..ab282428 100644 --- a/tests/Doc/SearchQuickstartExample.cs +++ b/tests/Doc/SearchQuickstartExample.cs @@ -38,7 +38,7 @@ public void run() Brand = "Velorim", Model = "Jigger", Price = 270M, - Description = "Small and powerful, the Jigger is the best ride " + + Description = "Small and powerful, the Jigger is the best ride " + "for the smallest of tikes! This is the tiniest " + "kids’ pedal bike on the market available without" + " a coaster brake, the Jigger is the vehicle of " + diff --git a/tests/Doc/SetGetExample.cs b/tests/Doc/SetGetExample.cs index 805b8868..a7da9411 100644 --- a/tests/Doc/SetGetExample.cs +++ b/tests/Doc/SetGetExample.cs @@ -31,7 +31,7 @@ public void run() Assert.True(status); Assert.Equal("Process 134", value.ToString()); //REMOVE_END - //HIDE_START + //HIDE_START } } //HIDE_END diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 4d1a7db3..4a63bdf0 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -95,7 +95,7 @@ public void TestCountFilterDoesNotExist() db.Execute("FLUSHALL"); var cf = db.CF(); - Assert.Equal(cf.Count("notExistFilter", "notExistItem"), 0); + Assert.Equal(0, cf.Count("notExistFilter", "notExistItem")); } [Fact] @@ -105,7 +105,7 @@ public async Task TestCountFilterDoesNotExistAsync() db.Execute("FLUSHALL"); var cf = db.CF(); - Assert.Equal(await cf.CountAsync("notExistFilter", "notExistItem"), 0); + Assert.Equal(0, await cf.CountAsync("notExistFilter", "notExistItem")); } [Fact] @@ -116,7 +116,7 @@ public void TestCountFilterExist() var cf = db.CF(); cf.Insert(key, new RedisValue[] { "foo" }); - Assert.Equal(cf.Count(key, "notExistItem"), 0); + Assert.Equal(0, cf.Count(key, "notExistItem")); } [Fact] @@ -127,7 +127,7 @@ public async Task TestCountFilterExistAsync() var cf = db.CF(); await cf.InsertAsync(key, new RedisValue[] { "foo" }); - Assert.Equal(await cf.CountAsync(key, "notExistItem"), 0); + Assert.Equal(0, await cf.CountAsync(key, "notExistItem")); } [Fact] @@ -138,7 +138,7 @@ public void TestCountItemExist() var cf = db.CF(); cf.Insert(key, new RedisValue[] { "foo" }); - Assert.Equal(cf.Count(key, "foo"), 1); + Assert.Equal(1, cf.Count(key, "foo")); } [Fact] @@ -149,7 +149,7 @@ public async Task TestCountItemExistAsync() var cf = db.CF(); await cf.InsertAsync(key, new RedisValue[] { "foo" }); - Assert.Equal(await cf.CountAsync(key, "foo"), 1); + Assert.Equal(1, await cf.CountAsync(key, "foo")); } [Fact] @@ -285,7 +285,7 @@ public void TestInsertNX() Assert.Equal(result, new bool[] { false, false, false }); // test empty items: - Assert.Throws(() => cf.InsertNX(key, new RedisValue[]{})); + Assert.Throws(() => cf.InsertNX(key, new RedisValue[] { })); } [Fact] @@ -313,7 +313,7 @@ public async Task TestInsertNXAsync() Assert.Equal(result, new bool[] { false, false, false }); // test empty items: - Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[]{})); + Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[] { })); } [Fact] diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 08a9f42d..58b65efe 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -43,7 +43,7 @@ public void TestCreateNode() Assert.Equal(2, stats.PropertiesSet); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // delete graph.Delete("social"); @@ -66,7 +66,7 @@ public void TestCreateLabeledNode() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // Assert.False(resultSet..iterator().MoveNext()); } @@ -94,7 +94,7 @@ public void TestConnectNodes() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] @@ -120,7 +120,7 @@ public void TestDeleteNodes() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); @@ -140,7 +140,7 @@ public void TestDeleteNodes() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -170,7 +170,7 @@ public void TestDeleteRelationship() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -936,7 +936,7 @@ public void TestConfig() Assert.True(graph.ConfigSet(name, 250L)); var actual = graph.ConfigGet(name); - Assert.Equal(actual.Count, 1); + Assert.Equal(1, actual.Count); Assert.Equal("250", actual[name].ToString()); graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); @@ -1026,7 +1026,7 @@ public async Task TestCreateNodeAsync() Assert.Equal(2, stats.PropertiesSet); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // delete await graph.DeleteAsync("social"); @@ -1049,7 +1049,7 @@ public async Task TestCreateLabeledNodeAsync() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // Assert.False(resultSet..iterator().MoveNext()); } @@ -1077,7 +1077,7 @@ public async Task TestConnectNodesAsync() // Assert.NotNull(stats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(stats.QueryInternalExecutionTime); - Assert.Equal(0, resultSet.Count); + Assert.Empty(resultSet); // Assert.False(resultSet.GetEnumerator().MoveNext()); } @@ -1104,7 +1104,7 @@ public async Task TestDeleteNodesAsync() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); @@ -1124,7 +1124,7 @@ public async Task TestDeleteNodesAsync() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -1154,7 +1154,7 @@ public async Task TestDeleteRelationshipAsync() Assert.Equal(0, delStats.PropertiesSet); // Assert.NotNull(delStats.getstringValue(Label.QUERY_INTERNAL_EXECUTION_TIME)); Assert.NotNull(delStats.QueryInternalExecutionTime); - Assert.Equal(0, deleteResult.Count); + Assert.Empty(deleteResult); // Assert.False(deleteResult.iterator().MoveNext()); } @@ -1909,7 +1909,7 @@ public async Task TestConfigAsync() Assert.True(await graph.ConfigSetAsync(name, 250L)); var actual = await graph.ConfigGetAsync(name); - Assert.Equal(actual.Count, 1); + Assert.Equal(1, actual.Count); Assert.Equal("250", actual[name].ToString()); await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); diff --git a/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs b/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs index 8dd7a921..7d30e546 100644 --- a/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs +++ b/tests/NRedisStack.Tests/Graph/Utils/PathBuilderTest.cs @@ -8,7 +8,7 @@ public class PathBuilderTest [Fact] public void TestPathBuilderSizeException() { - var thrownException = Assert.Throws(()=> + var thrownException = Assert.Throws(() => { var pathBuilder = new PathBuilder(0); diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 718afb0d..82d40699 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -775,12 +775,12 @@ public void Merge() // Create a connection to Redis var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); - Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); + Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new { home = "123 Main Street" }, phone = "123-456-7890" } })); Assert.True(commands.Merge("test_merge", "$", new { person = new { age = 30 } })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\"},\"phone\":\"123-456-7890\"}}", commands.Get("test_merge").ToString()); // Test with root path path $.a.b - Assert.True(commands.Merge("test_merge", "$.person.address", new {work = "Redis office"})); + Assert.True(commands.Merge("test_merge", "$.person.address", new { work = "Redis office" })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"},\"phone\":\"123-456-7890\"}}", commands.Get("test_merge").ToString()); // Test with null value to delete a value @@ -794,12 +794,12 @@ public async Task MergeAsync() // Create a connection to Redis var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); - Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new {home = "123 Main Street"}, phone = "123-456-7890" } })); + Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new { home = "123 Main Street" }, phone = "123-456-7890" } })); Assert.True(await commands.MergeAsync("test_merge", "$", new { person = new { age = 30 } })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\"},\"phone\":\"123-456-7890\"}}", (await commands.GetAsync("test_merge")).ToString()); // Test with root path path $.a.b - Assert.True(await commands.MergeAsync("test_merge", "$.person.address", new {work = "Redis office"})); + Assert.True(await commands.MergeAsync("test_merge", "$.person.address", new { work = "Redis office" })); Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"age\":30,\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"},\"phone\":\"123-456-7890\"}}", (await commands.GetAsync("test_merge")).ToString()); // Test with null value to delete a value diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 41369e21..592dcfce 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -39,7 +39,7 @@ public async Task TestModulsPipeline() Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("graph-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); @@ -88,7 +88,7 @@ public async Task TestModulsPipelineWithotGraph() Assert.False(db.KeyExists("cms-key")); Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); @@ -122,19 +122,19 @@ public async Task TestBloomPipeline() var pipeline = new Pipeline(db); pipeline.Bf.ReserveAsync(key, 0.001, 100); - for(int i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { pipeline.Bf.AddAsync(key, i.ToString()); } - for(int i = 0; i < 100; i++) + for (int i = 0; i < 100; i++) { Assert.False(db.BF().Exists(key, i.ToString())); } pipeline.Execute(); - for(int i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { Assert.True(db.BF().Exists(key, i.ToString())); } diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 88669f9d..5caf53b5 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -177,7 +177,6 @@ public void TestAggregations() Assert.Equal(2, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("def", r1.GetString("name")); Assert.Equal(30, r1.GetLong("sum")); Assert.Equal(30, r1.GetDouble("sum"), 0); @@ -187,7 +186,6 @@ public void TestAggregations() Assert.Null(r1.GetString("nosuchcol")); Row r2 = res.GetRow(1); - Assert.NotNull(r2); Assert.Equal("abc", r2.GetString("name")); Assert.Equal(10, r2.GetLong("sum")); } @@ -218,7 +216,6 @@ public async Task TestAggregationsAsync() Assert.Equal(2, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("def", r1.GetString("name")); Assert.Equal(30, r1.GetLong("sum")); Assert.Equal(30, r1.GetDouble("sum"), 0); @@ -228,7 +225,6 @@ public async Task TestAggregationsAsync() Assert.Null(r1.GetString("nosuchcol")); Row r2 = res.GetRow(1); - Assert.NotNull(r2); Assert.Equal("abc", r2.GetString("name")); Assert.Equal(10, r2.GetLong("sum")); } @@ -248,18 +244,18 @@ public void TestAggregationsLoad() // load t1 var req = new AggregationRequest("*").Load(new FieldName("t1")); var res = ft.Aggregate("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); + Assert.Equal("hello", res[0]["t1"].ToString()); // load t2 req = new AggregationRequest("*").Load(new FieldName("t2")); res = ft.Aggregate("idx", req); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("world", res[0]["t2"]); // load all req = new AggregationRequest("*").LoadAll(); res = ft.Aggregate("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("hello", res[0]["t1"].ToString()); + Assert.Equal("world", res[0]["t2"]); } [SkipIfRedis(Is.Cluster)] @@ -276,18 +272,18 @@ public async Task TestAggregationsLoadAsync() // load t1 var req = new AggregationRequest("*").Load(new FieldName("t1")); var res = await ft.AggregateAsync("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); + Assert.Equal("hello", res[0]["t1"].ToString()); // load t2 req = new AggregationRequest("*").Load(new FieldName("t2")); res = await ft.AggregateAsync("idx", req); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("world", res[0]["t2"]); // load all req = new AggregationRequest("*").LoadAll(); res = await ft.AggregateAsync("idx", req); - Assert.Equal(res[0]["t1"].ToString(), "hello"); - Assert.Equal(res[0]["t2"], "world"); + Assert.Equal("hello", res[0]["t1"].ToString()); + Assert.Equal("world", res[0]["t2"]); } @@ -319,7 +315,6 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -355,7 +350,6 @@ public async Task TestAggregationRequestParamsDialectAsync() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -387,7 +381,6 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -419,7 +412,6 @@ public async Task TestAggregationRequestParamsWithDefaultDialectAsync() Assert.Equal(1, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("abc", r1.GetString("name")); Assert.Equal(10, r1.GetLong("sum")); } @@ -525,12 +517,10 @@ public void TestApplyAndFilterAggregations() Assert.Equal(3, res.TotalResults); Row r1 = res.GetRow(0); - Assert.NotNull(r1); Assert.Equal("def", r1.GetString("name")); Assert.Equal(52.5, r1.GetDouble("avgscore"), 0); Row r2 = res.GetRow(1); - Assert.NotNull(r2); Assert.Equal("ghi", r2.GetString("name")); Assert.Equal(67.5, r2.GetDouble("avgscore"), 0); } @@ -748,7 +738,7 @@ public void AlterAdd() var info = ft.Info(index); Assert.Equal(index, info.IndexName); - Assert.Equal(0, info.IndexOption.Count); + Assert.Empty(info.IndexOption); // Assert.Equal(,info.IndexDefinition); Assert.Equal("title", (info.Attributes[0]["identifier"]).ToString()); Assert.Equal("TAG", (info.Attributes[1]["type"]).ToString()); @@ -1090,68 +1080,68 @@ public void TestAggregationGroupBy() var req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Count()); var res = ft.Aggregate("idx", req).GetRow(0); Assert.True(res.ContainsKey("parent")); - Assert.Equal(res["parent"], "redis"); + Assert.Equal("redis", res["parent"]); // Assert.Equal(res["__generated_aliascount"], "3"); req = new AggregationRequest("redis").GroupBy("@parent", Reducers.CountDistinct("@title")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliascount_distincttitle"), 3); + Assert.Equal("redis", res["parent"]); + Assert.Equal(3, res.GetLong("__generated_aliascount_distincttitle")); req = new AggregationRequest("redis").GroupBy("@parent", Reducers.CountDistinctish("@title")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliascount_distinctishtitle"), 3); + Assert.Equal("redis", res["parent"]); + Assert.Equal(3, res.GetLong("__generated_aliascount_distinctishtitle")); req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Sum("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliassumrandom_num"), 21); // 10+8+3 + Assert.Equal("redis", res["parent"]); + Assert.Equal(21, res.GetLong("__generated_aliassumrandom_num")); // 10+8+3 req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Min("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasminrandom_num"), 3); // min(10,8,3) + Assert.Equal("redis", res["parent"]); + Assert.Equal(3, res.GetLong("__generated_aliasminrandom_num")); // min(10,8,3) req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Max("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasmaxrandom_num"), 10); // max(10,8,3) + Assert.Equal("redis", res["parent"]); + Assert.Equal(10, res.GetLong("__generated_aliasmaxrandom_num")); // max(10,8,3) req = new AggregationRequest("redis").GroupBy("@parent", Reducers.Avg("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasavgrandom_num"), 7); // (10+3+8)/3 + Assert.Equal("redis", res["parent"]); + Assert.Equal(7, res.GetLong("__generated_aliasavgrandom_num")); // (10+3+8)/3 req = new AggregationRequest("redis").GroupBy("@parent", Reducers.StdDev("@random_num")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetDouble("__generated_aliasstddevrandom_num"), 3.60555127546); + Assert.Equal("redis", res["parent"]); + Assert.Equal(3.60555127546, res.GetDouble("__generated_aliasstddevrandom_num")); req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.Quantile("@random_num", 0.5)); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res.GetLong("__generated_aliasquantilerandom_num,0.5"), 8); // median of 3,8,10 + Assert.Equal("redis", res["parent"]); + Assert.Equal(8, res.GetLong("__generated_aliasquantilerandom_num,0.5")); // median of 3,8,10 req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.ToList("@title")); var rawRes = ft.Aggregate("idx", req); res = rawRes.GetRow(0); - Assert.Equal(res["parent"], "redis"); + Assert.Equal("redis", res["parent"]); // TODO: complete this assert after handling multi bulk reply //Assert.Equal((RedisValue[])res["__generated_aliastolisttitle"], { "RediSearch", "RedisAI", "RedisJson"}); req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.FirstValue("@title").As("first")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); - Assert.Equal(res["first"], "RediSearch"); + Assert.Equal("redis", res["parent"]); + Assert.Equal("RediSearch", res["first"]); req = new AggregationRequest("redis").GroupBy( "@parent", Reducers.RandomSample("@title", 2).As("random")); res = ft.Aggregate("idx", req).GetRow(0); - Assert.Equal(res["parent"], "redis"); + Assert.Equal("redis", res["parent"]); // TODO: complete this assert after handling multi bulk reply // Assert.Equal(res[2], "random"); // Assert.Equal(len(res[3]), 2); @@ -1177,7 +1167,7 @@ public void TestDictionary() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, ft.DictDel("dict", "foo", "bar", "hello world")); - Assert.Equal(ft.DictDump("dict").Length, 0); + Assert.Equal(0, ft.DictDump("dict").Length); } [SkipIfRedis(Is.Cluster)] @@ -1208,7 +1198,7 @@ public void TestDropIndex() } catch (RedisServerException ex) { - Assert.True(ex.Message.Contains("no such index")); + Assert.Contains("no such index", ex.Message); } Assert.Equal("100", db.Execute("DBSIZE").ToString()); } @@ -1241,7 +1231,7 @@ public async Task TestDropIndexAsync() } catch (RedisServerException ex) { - Assert.True(ex.Message.Contains("no such index")); + Assert.Contains("no such index", ex.Message); } Assert.Equal("100", db.Execute("DBSIZE").ToString()); } @@ -1314,7 +1304,7 @@ public async Task TestDictionaryAsync() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, await ft.DictDelAsync("dict", "foo", "bar", "hello world")); - Assert.Equal((await ft.DictDumpAsync("dict")).Length, 0); + Assert.Equal(0, (await ft.DictDumpAsync("dict")).Length); } string explainQuery = "@f3:f3_val @f2:f2_val @f1:f1_val"; @@ -1552,19 +1542,19 @@ public async Task GetTagFieldSyncAsync() var SyncRes = ft.TagVals(index, "category"); int i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange;purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange;purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); var AsyncRes = await ft.TagValsAsync(index, "category"); i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange;purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange;purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); } [SkipIfRedis(Is.Cluster)] @@ -1610,19 +1600,19 @@ public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync() var SyncRes = ft.TagVals(index, "category"); int i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange,purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange,purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); var AsyncRes = await ft.TagValsAsync(index, "category"); i = 0; - Assert.Equal(SyncRes[i++].ToString(), "blue"); - Assert.Equal(SyncRes[i++].ToString(), "green"); - Assert.Equal(SyncRes[i++].ToString(), "orange,purple"); - Assert.Equal(SyncRes[i++].ToString(), "red"); - Assert.Equal(SyncRes[i++].ToString(), "yellow"); + Assert.Equal("blue", SyncRes[i++].ToString()); + Assert.Equal("green", SyncRes[i++].ToString()); + Assert.Equal("orange,purple", SyncRes[i++].ToString()); + Assert.Equal("red", SyncRes[i++].ToString()); + Assert.Equal("yellow", SyncRes[i++].ToString()); } @@ -1889,7 +1879,7 @@ public void TestQueryCommandBuilder() var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("txt")); var res = ft.Search("idx", testQuery); - Assert.Equal(0, res.Documents.Count()); + Assert.Empty(res.Documents); } [Fact] @@ -1925,7 +1915,7 @@ public void TestQueryCommandBuilderReturnField() var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("txt")); var res = ft.Search("idx", testQuery); - Assert.Equal(0, res.Documents.Count()); + Assert.Empty(res.Documents); } [SkipIfRedis(Is.Cluster)] @@ -2019,8 +2009,8 @@ public void TestLimit() var req = new AggregationRequest("*").SortBy("@t1").Limit(1); var res = ft.Aggregate("idx", req); - Assert.Equal(res.GetResults().Count, 1); - Assert.Equal(res.GetResults()[0]["t1"].ToString(), "a"); + Assert.Equal(1, res.GetResults().Count); + Assert.Equal("a", res.GetResults()[0]["t1"].ToString()); } [SkipIfRedis(Is.Cluster)] @@ -2039,8 +2029,8 @@ public async Task TestLimitAsync() var req = new AggregationRequest("*").SortBy("@t1").Limit(1, 1); var res = await ft.AggregateAsync("idx", req); - Assert.Equal(res.GetResults().Count, 1); - Assert.Equal(res.GetResults()[0]["t1"].ToString(), "b"); + Assert.Equal(1, res.GetResults().Count); + Assert.Equal("b", res.GetResults()[0]["t1"].ToString()); } [Fact] @@ -2435,7 +2425,7 @@ public void TestAddAndGetSuggestion() Assert.Equal(1, ft.SugGet(key, suggestion.Substring(0, 3), true, max: 5).Count); // turn off fuzzy start at second word no hit - Assert.Equal(0, ft.SugGet(key, noMatch.Substring(1, 6), false, max: 5).Count); + Assert.Empty(ft.SugGet(key, noMatch.Substring(1, 6), false, max: 5)); // my attempt to trigger the fuzzy by 1 character Assert.Equal(1, ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5).Count); @@ -2458,7 +2448,7 @@ public async Task TestAddAndGetSuggestionAsync() Assert.Equal(1, (await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5)).Count); // turn off fuzzy start at second word no hit - Assert.Equal(0, (await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5)).Count); + Assert.Empty((await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5))); // my attempt to trigger the fuzzy by 1 character Assert.Equal(1, (await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)).Count); @@ -2574,8 +2564,8 @@ public void getSuggestionNoHit() var ft = db.FT(); ft.SugAdd(key, "NO WORD", 0.4); - Assert.Equal(0, ft.SugGetWithScores(key, "DIF").Count); - Assert.Equal(0, ft.SugGet(key, "DIF").Count); + Assert.Empty(ft.SugGetWithScores(key, "DIF")); + Assert.Empty(ft.SugGet(key, "DIF")); } [Fact] @@ -2586,8 +2576,8 @@ public async Task getSuggestionNoHitAsync() var ft = db.FT(); await ft.SugAddAsync(key, "NO WORD", 0.4); - Assert.Equal(0, (await ft.SugGetWithScoresAsync(key, "DIF")).Count); - Assert.Equal(0, (await ft.SugGetAsync(key, "DIF")).Count); + Assert.Empty((await ft.SugGetWithScoresAsync(key, "DIF"))); + Assert.Empty((await ft.SugGetAsync(key, "DIF"))); } [Fact] @@ -2702,16 +2692,16 @@ public void TestProfile() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count, 5); - Assert.Equal(searchRes.Documents.Count, 2); + Assert.Equal(5, searchDet.Count); + Assert.Equal(2, searchRes.Documents.Count); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = ft.ProfileAggregate(index, aggReq); var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count, 5); - Assert.Equal(aggregateRes.TotalResults, 1); + Assert.Equal(5, aggregateDet.Count); + Assert.Equal(1, aggregateRes.TotalResults); } [Fact] @@ -2731,16 +2721,16 @@ public async Task TestProfileAsync() var searchRes = profileSearch.Item1; var searchDet = profileSearch.Item2; - Assert.Equal(searchDet.Count, 5); - Assert.Equal(searchRes.Documents.Count, 2); + Assert.Equal(5, searchDet.Count); + Assert.Equal(2, searchRes.Documents.Count); // check using AggregationRequest var aggReq = new AggregationRequest("*").Load(FieldName.Of("t")).Apply("startswith(@t, 'hel')", "prefix"); var profileAggregate = await ft.ProfileAggregateAsync(index, aggReq); var aggregateRes = profileAggregate.Item1; var aggregateDet = profileAggregate.Item2; - Assert.Equal(aggregateDet.Count, 5); - Assert.Equal(aggregateRes.TotalResults, 1); + Assert.Equal(5, aggregateDet.Count); + Assert.Equal(1, aggregateRes.TotalResults); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index ce15694c..2fc943f7 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -57,8 +57,8 @@ public void TestAlterPolicyAndChunk() ts.Create(key); Assert.True(ts.Alter(key, chunkSizeBytes: 128, duplicatePolicy: TsDuplicatePolicy.MIN)); TimeSeriesInformation info = ts.Info(key); - Assert.Equal(info.ChunkSize, 128); - Assert.Equal(info.DuplicatePolicy, TsDuplicatePolicy.MIN); + Assert.Equal(128, info.ChunkSize); + Assert.Equal(TsDuplicatePolicy.MIN, info.DuplicatePolicy); } } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs index 688860e9..05a992ce 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs @@ -56,8 +56,8 @@ public async Task TestAlterPolicyAndChunkAsync() ts.Create(key); Assert.True(await ts.AlterAsync(key, chunkSizeBytes: 128, duplicatePolicy: TsDuplicatePolicy.MIN)); TimeSeriesInformation info = ts.Info(key); - Assert.Equal(info.ChunkSize, 128); - Assert.Equal(info.DuplicatePolicy, TsDuplicatePolicy.MIN); + Assert.Equal(128, info.ChunkSize); + Assert.Equal(TsDuplicatePolicy.MIN, info.DuplicatePolicy); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs index f4432c16..9318fd07 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs @@ -28,16 +28,16 @@ public void TestInformationSync() Assert.Equal(4184, info.MemoryUsage); Assert.Equal(0, info.RetentionTime); Assert.Equal(1, info.ChunkCount); - Assert.Equal(null, info.DuplicatePolicy); + Assert.Null(info.DuplicatePolicy); Assert.Null(info.KeySelfName); Assert.Null(info.Chunks); Assert.Equal(4184, infoDebug.MemoryUsage); Assert.Equal(0, infoDebug.RetentionTime); Assert.Equal(1, infoDebug.ChunkCount); - Assert.Equal(null, infoDebug.DuplicatePolicy); + Assert.Null(infoDebug.DuplicatePolicy); Assert.Equal(infoDebug.KeySelfName, key); - Assert.Equal(infoDebug.Chunks.Count, 1); + Assert.Equal(1, infoDebug.Chunks!.Count); } [Fact] @@ -56,16 +56,16 @@ public async Task TestInformationAsync() Assert.Equal(4184, info.MemoryUsage); Assert.Equal(0, info.RetentionTime); Assert.Equal(1, info.ChunkCount); - Assert.Equal(null, info.DuplicatePolicy); + Assert.Null(info.DuplicatePolicy); Assert.Null(info.KeySelfName); Assert.Null(info.Chunks); Assert.Equal(4184, infoDebug.MemoryUsage); Assert.Equal(0, infoDebug.RetentionTime); Assert.Equal(1, infoDebug.ChunkCount); - Assert.Equal(null, infoDebug.DuplicatePolicy); + Assert.Null(infoDebug.DuplicatePolicy); Assert.Equal(infoDebug.KeySelfName, key); - Assert.Equal(infoDebug.Chunks.Count, 1); + Assert.Equal(1, infoDebug.Chunks!.Count); } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 87ab2bac..7e8ddada 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -25,7 +25,7 @@ public void CreateTopKFilter() topk.Reserve(key, 30, 2000, 7, 0.925); var res = topk.Add(key, "bb", "cc"); - Assert.True(res[0].IsNull && res[1].IsNull); + Assert.True(res![0].IsNull && res[1].IsNull); Assert.Equal(topk.Query(key, "bb", "gg", "cc"), new bool[] { true, false, true }); Assert.False(topk.Query(key, "notExists")); @@ -33,23 +33,23 @@ public void CreateTopKFilter() Assert.Equal(topk.Count(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); var res2 = topk.List(key); - Assert.Equal(res2[0].ToString(), "bb"); - Assert.Equal(res2[1].ToString(), "cc"); + Assert.Equal("bb", res2[0].ToString()); + Assert.Equal("cc", res2[1].ToString()); var tuple = new Tuple("ff", 10); var del = topk.IncrBy(key, tuple); Assert.True(topk.IncrBy(key, tuple)[0].IsNull); res2 = topk.List(key); - Assert.Equal(res2[0].ToString(), "ff"); - Assert.Equal(res2[1].ToString(), "bb"); - Assert.Equal(res2[2].ToString(), "cc"); + Assert.Equal("ff", res2[0].ToString()); + Assert.Equal("bb", res2[1].ToString()); + Assert.Equal("cc", res2[2].ToString()); var info = topk.Info(key); - Assert.Equal(info.Decay, 0.925); - Assert.Equal(info.Depth, 7); - Assert.Equal(info.K, 30); - Assert.Equal(info.Width, 2000); + Assert.Equal(0.925, info.Decay); + Assert.Equal(7, info.Depth); + Assert.Equal(30, info.K); + Assert.Equal(2000, info.Width); } [Fact] @@ -70,22 +70,22 @@ public async Task CreateTopKFilterAsync() Assert.Equal(await topk.CountAsync(key, "bb", "gg", "cc"), new long[] { 1, 0, 1 }); var res2 = await topk.ListAsync(key); - Assert.Equal(res2[0].ToString(), "bb"); - Assert.Equal(res2[1].ToString(), "cc"); + Assert.Equal("bb", res2[0].ToString()); + Assert.Equal("cc", res2[1].ToString()); var tuple = new Tuple("ff", 10); Assert.True((await topk.IncrByAsync(key, tuple))[0].IsNull); res2 = await topk.ListAsync(key); - Assert.Equal(res2[0].ToString(), "ff"); - Assert.Equal(res2[1].ToString(), "bb"); - Assert.Equal(res2[2].ToString(), "cc"); + Assert.Equal("ff", res2[0].ToString()); + Assert.Equal("bb", res2[1].ToString()); + Assert.Equal("cc", res2[2].ToString()); var info = await topk.InfoAsync(key); - Assert.Equal(info.Decay, 0.925); - Assert.Equal(info.Depth, 7); - Assert.Equal(info.K, 30); - Assert.Equal(info.Width, 2000); + Assert.Equal(0.925, info.Decay); + Assert.Equal(7, info.Depth); + Assert.Equal(30, info.K); + Assert.Equal(2000, info.Width); } [Fact] diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 48d9dd14..10618576 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -55,7 +55,7 @@ public async Task TestModulsTransaction() Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("graph-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); @@ -104,7 +104,7 @@ public async Task TestModulsTransactionWithoutGraph() Assert.False(db.KeyExists("cms-key")); Assert.False(db.KeyExists("cf-key")); Assert.False(db.KeyExists("json-key")); - Assert.Equal(0, db.FT()._List().Length); + Assert.Empty(db.FT()._List()); Assert.False(db.KeyExists("tdigest-key")); Assert.False(db.KeyExists("ts-key")); Assert.False(db.KeyExists("topk-key")); From a42fee6d455ddcd94dc55198fa55b183ed458a31 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 11:58:05 +0300 Subject: [PATCH 35/48] Clean Warnings --- Examples/AdvancedJsonExamples.md | 89 ++++++++-- Examples/AdvancedQueryOperations.md | 94 +++++++--- Examples/AsyncExample.md | 2 +- Examples/BasicJsonExamples.md | 165 +++++++++++++++--- Examples/BasicQueryOperations.md | 113 ++++++++++-- Examples/ConvertSearchResultToJson.md | 15 +- Examples/HsetAndSearch.md | 22 ++- Examples/PipelineExample.md | 12 +- Examples/PipelineWithAsync.md | 6 + src/NRedisStack/Graph/ResultSet.cs | 23 +-- src/NRedisStack/Json/JsonCommandBuilder.cs | 2 +- src/NRedisStack/Json/JsonCommandsAsync.cs | 4 +- src/NRedisStack/ResponseParser.cs | 61 +++---- src/NRedisStack/Search/Document.cs | 10 +- src/NRedisStack/Search/FTCreateParams.cs | 16 +- src/NRedisStack/Search/FieldName.cs | 4 +- src/NRedisStack/Search/Query.cs | 26 +-- src/NRedisStack/Search/SearchResult.cs | 12 +- .../DataTypes/TimeSeriesInformation.cs | 18 +- tests/NRedisStack.Tests/Graph/GraphTests.cs | 78 ++++----- tests/NRedisStack.Tests/Search/SearchTests.cs | 12 +- 21 files changed, 569 insertions(+), 215 deletions(-) diff --git a/Examples/AdvancedJsonExamples.md b/Examples/AdvancedJsonExamples.md index aa597d74..e9f33e5d 100644 --- a/Examples/AdvancedJsonExamples.md +++ b/Examples/AdvancedJsonExamples.md @@ -1,24 +1,30 @@ # Advanced JSON + Redis JSON array filtering examples + ## Contents -1. [Business Value Statement](#value) -2. [Data Set](#dataset) -3. [Data Loading](#dataload) -4. [Array Filtering Examples](#arrayfiltering) - 1. [All Properties of Array](#allprops) - 2. [All Properties of a Field](#allfield) - 3. [Relational - Equality](#equality) - 4. [Relational - Less Than](#lessthan) - 5. [Relational - Greater Than or Equal](#greaterthan) - 6. [Logical AND](#logicaland) - 7. [Logical OR](#logicalor) - 8. [Regex - Contains Exact](#regex_exact) - 9. [Regex - Contains, Case Insensitive](#regex_contains) - 10. [Regex - Begins With](#regex_begins) + +1. [Business Value Statement](#value) +2. [Data Set](#dataset) +3. [Data Loading](#dataload) +4. [Array Filtering Examples](#arrayfiltering) + 1. [All Properties of Array](#allprops) + 2. [All Properties of a Field](#allfield) + 3. [Relational - Equality](#equality) + 4. [Relational - Less Than](#lessthan) + 5. [Relational - Greater Than or Equal](#greaterthan) + 6. [Logical AND](#logicaland) + 7. [Logical OR](#logicalor) + 8. [Regex - Contains Exact](#regex_exact) + 9. [Regex - Contains, Case Insensitive](#regex_contains) + 10. [Regex - Begins With](#regex_begins) ## Business Value Statement + The ability to query within a JSON object unlocks further value to the underlying data. Redis supports JSONPath array filtering natively. + ## Data Set + ```JSON { "city": "Boston", @@ -48,7 +54,9 @@ The ability to query within a JSON object unlocks further value to the underlyin ] } ``` + ## Data Loading + ```c# JsonCommands json = db.JSON(); json.Set("warehouse:1", "$", new { @@ -79,13 +87,19 @@ json.Set("warehouse:1", "$", new { } }); ``` + ## Array Filtering Examples + ### Syntax + [JSON.GET](https://redis.io/commands/json.get/) ### All Properties of Array + Fetch all properties of an array. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[*]", @@ -93,7 +107,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -131,8 +147,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### All Properties of a Field + Fetch all values of a field within an array. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[*].price", @@ -140,7 +159,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ 34.95, @@ -150,8 +171,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Relational - Equality + Fetch all items within an array where a text field matches a given value. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.description==\"Turtle Check Men Navy Blue Shirt\")]", @@ -159,7 +183,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -176,8 +202,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Relational - Less Than + Fetch all items within an array where a numeric field is less than a given value. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.price<100)]", @@ -185,7 +214,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -211,8 +242,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Relational - Greater Than or Equal + Fetch all items within an array where a numeric field is greater than or equal to a given value. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.id>=20000)]", @@ -220,7 +254,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -248,8 +284,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Logical AND + Fetch all items within an array that meet two relational operations. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.gender==\"Men\"&&@.price>20)]", @@ -257,7 +296,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -274,8 +315,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Logical OR + Fetch all items within an array that meet at least one relational operation. In this case, return only the ids of those items. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.price<100||@.gender==\"Women\")].id", @@ -283,7 +327,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ 15970, @@ -293,8 +339,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Regex - Contains Exact + Fetch all items within an array that match a given regex pattern. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.description =~ \"Blue\")]", @@ -302,7 +351,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -328,8 +379,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Regex - Contains, Case Insensitive + Fetch all items within an array where a field contains a term, case insensitive. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.description =~ \"(?i)watch\")]", @@ -337,7 +391,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { @@ -356,8 +412,11 @@ Console.WriteLine(json.Get(key: "warehouse:1", ``` ### Regex - Begins With + Fetch all items within an array where a field begins with a given expression. + #### Command + ```c# Console.WriteLine(json.Get(key: "warehouse:1", path: "$.inventory[?(@.description =~ \"^T\")]", @@ -365,7 +424,9 @@ Console.WriteLine(json.Get(key: "warehouse:1", newLine: "\n" )); ``` + #### Result + ```json [ { diff --git a/Examples/AdvancedQueryOperations.md b/Examples/AdvancedQueryOperations.md index 4573e60c..74cad845 100644 --- a/Examples/AdvancedQueryOperations.md +++ b/Examples/AdvancedQueryOperations.md @@ -1,33 +1,38 @@ # Advanced Querying Aggregation and other more complex RediSearch queries + ## Contents -1. [Business Value Statement](#value) -2. [Modules Needed](#modules) -3. [Vector Similarity Search](#vss) - 1. [Data Load](#vss_dataload) - 2. [Index Creation](#vss_index) - 3. [Search](#vss_search) - 4. [Hybrid Query Search](#vss_hybrid_query_search) -4. [Advanced Search Queries](#adv_search) - 1. [Data Set](#advs_dataset) - 2. [Data Load](#advs_dataload) - 3. [Index Creation](#advs_index) - 4. [Search w/JSON Filtering - Example 1](#advs_ex1) - 5. [Search w/JSON Filtering - Example 2](#advs_ex2) -5. [Aggregation](#aggr) - 1. [Data Set](#aggr_dataset) - 2. [Data Load](#aggr_dataload) - 3. [Index Creation](#aggr_index) - 4. [Aggregation - Count](#aggr_count) - 5. [Aggregation - Sum](#aggr_sum) + +1. [Business Value Statement](#value) +2. [Modules Needed](#modules) +3. [Vector Similarity Search](#vss) + 1. [Data Load](#vss_dataload) + 2. [Index Creation](#vss_index) + 3. [Search](#vss_search) + 4. [Hybrid Query Search](#vss_hybrid_query_search) +4. [Advanced Search Queries](#adv_search) + 1. [Data Set](#advs_dataset) + 2. [Data Load](#advs_dataload) + 3. [Index Creation](#advs_index) + 4. [Search w/JSON Filtering - Example 1](#advs_ex1) + 5. [Search w/JSON Filtering - Example 2](#advs_ex2) +5. [Aggregation](#aggr) + 1. [Data Set](#aggr_dataset) + 2. [Data Load](#aggr_dataload) + 3. [Index Creation](#aggr_index) + 4. [Aggregation - Count](#aggr_count) + 5. [Aggregation - Sum](#aggr_sum) ## Business Value Statement + Redis provides the following additional advanced search capabilities to derive further value of Redis-held data: + * Vector Similarity Search - Store and search by ML-generated encodings of text and images * Search + JSON Filtering - Combine the power of search with JSONPath filtering of search results * Aggregation - Create processing pipelines of search results to extract analytic insights. ## Modules Needed + ```c# using StackExchange.Redis; using NRedisStack; @@ -36,11 +41,15 @@ using NRedisStack.Search; using NRedisStack.Search.Literals.Enums; using NRedisStack.Search.Aggregation; ``` + ## Vector Similarity Search (VSS) + ### Syntax + [VSS](https://redis.io/docs/stack/search/reference/vectors/) ### Data Load + ```c# db.HashSet("vec:1", new HashEntry[] { @@ -63,8 +72,11 @@ db.HashSet("vec:4", new HashEntry[] new("tag", "A") }); ``` + ### Index Creation + #### Command + ```c# SearchCommands ft = db.FT(); try {ft.DropIndex("vss_idx");} catch {}; @@ -80,13 +92,17 @@ Console.WriteLine(ft.Create("vss_idx", new FTCreateParams().On(IndexDataType.HAS } ))); ``` + #### Result + ```bash True ``` ### Search + #### Command + ```c# float[] vec = new[] { 2f, 3f, 3f, 3f}; var res = ft.Search("vss_idx", @@ -102,14 +118,18 @@ foreach (var doc in res.Documents) { } } ``` + #### Result + ```bash id: vec:2, score: 2 id: vec:3, score: 2 ``` ### Hybrid query Search + #### Search only documents with tag A + ```c# float[] vec = new[] { 2f, 3f, 3f, 3f}; var res = ft.Search("vss_idx", @@ -125,15 +145,21 @@ foreach (var doc in res.Documents) { } } ``` + #### Result + ```bash id: vec:2, score: 3 id: vec:4, score: 7 ``` + vec:3 is not returned because it has tag B ## Advanced Search Queries + + ### Data Set + ```json { "city": "Boston", @@ -192,6 +218,7 @@ vec:3 is not returned because it has tag B ``` ### Data Load + ```c# JsonCommands json = db.JSON(); json.Set("warehouse:1", "$", new { @@ -251,7 +278,9 @@ json.Set("warehouse:2", "$", new { ``` ### Index Creation + #### Command + ```c# SearchCommands ft = db.FT(); try {ft.DropIndex("wh_idx");} catch {}; @@ -260,14 +289,19 @@ Console.WriteLine(ft.Create("wh_idx", new FTCreateParams() .Prefix("warehouse:"), new Schema().AddTextField(new FieldName("$.city", "city")))); ``` + #### Result + ```bash True ``` ### Search w/JSON Filtering - Example 1 + Find all inventory ids from all the Boston warehouse that have a price > $50. + #### Command + ```c# foreach (var doc in ft.Search("wh_idx", new Query("@city:Boston") @@ -278,14 +312,19 @@ foreach (var doc in ft.Search("wh_idx", Console.WriteLine(doc); } ``` + #### Result + ```json [59263] ``` ### Search w/JSON Filtering - Example 2 + Find all inventory items in Dallas that are for Women or Girls + #### Command + ```c# foreach (var doc in ft.Search("wh_idx", new Query("@city:(Dallas)") @@ -296,7 +335,9 @@ foreach (var doc in ft.Search("wh_idx", Console.WriteLine(doc); } ``` + #### Result + ```json [{"id":51919,"gender":"Women","season":["Summer"],"description":"Nyk Black Horado Handbag","price":52.49},{"id":37561,"gender":"Girls","season":["Spring","Summer"],"description":"Madagascar3 Infant Pink Snapsuit Romper","price":23.95}] ``` @@ -353,7 +394,9 @@ json.Set("book:4", "$", new { ``` ### Index Creation + #### Command + ```c# Console.WriteLine(ft.Create("book_idx", new FTCreateParams() .On(IndexDataType.JSON) @@ -362,14 +405,19 @@ Console.WriteLine(ft.Create("book_idx", new FTCreateParams() .AddNumericField(new FieldName("$.year", "year")) .AddNumericField(new FieldName("$.price", "price")))); ``` + #### Result + ```bash True ``` ### Aggregation - Count + Find the total number of books per year + #### Command + ```c# var request = new AggregationRequest("*").GroupBy("@year", Reducers.Count().As("count")); var result = ft.Aggregate("book_idx", request); @@ -379,7 +427,9 @@ for (var i=0; i + Sum of inventory dollar value by year #### Command + ```c# request = new AggregationRequest("*").GroupBy("@year", Reducers.Sum("@price").As("sum")); result = ft.Aggregate("book_idx", request); @@ -398,9 +450,11 @@ for (var i=0; i + Document stores are a NoSQL database type that provide flexible schemas and access patterns familiar to developers. Redis natively provides document store functionality with its JSON data type. Hence, Redis complements existing document store databases such as MongoDB or provides standalone JSON document storage. ## Create + ### Syntax + [JSON.SET](https://redis.io/commands/json.set/) ### Key-value pair + Insert a simple KVP as a JSON object. + #### Command + ```c# JsonCommands json = db.JSON(); Console.WriteLine(json.Set("ex1:1", "$", "\"val\"")); ``` + #### Result + ```bash True ``` - ### Single string property + Insert a single-property JSON object. + #### Command + ```c# Console.WriteLine(json.Set("ex1:2", "$", new {field1 = "val1" })); ``` + #### Result + ```bash True ``` ### Multiple Properties + Insert a JSON object with multiple properties. + #### Command + ```c# Console.WriteLine(json.Set("ex1:3", "$", new { field1 = "val1", field2 = "val2" })); ``` + #### Result + ```bash True ``` ### Multiple Properties + Data Types + Insert a JSON object with multiple properties of different data types. + #### Command + ```c# Console.WriteLine(json.Set("ex1:4", "$", new { field1 = "val1", @@ -83,27 +106,37 @@ Console.WriteLine(json.Set("ex1:4", "$", new { field4 = (string?) null })); ``` + #### Result + ```bash True ``` ### JSON Arrays + Insert a JSON object that contains an array. + #### Command + ```c# Console.WriteLine(json.Set("ex1:5", "$", new { arr1 = new [] {"val1", "val2", "val3"} })); ``` + #### Result + ```bash True ``` ### JSON Objects + Insert a JSON object that contains a nested object. + #### Command + ```c# Console.WriteLine(json.Set("ex1:6", "$", new { obj1 = new { @@ -112,14 +145,19 @@ Console.WriteLine(json.Set("ex1:6", "$", new { } })); ``` + #### Result + ```bash True ``` ### Mix + Insert a JSON object with a mixture of property data types. + #### Command + ```c# Console.WriteLine(json.Set("ex1:7", "$", new { str1 = "val1", @@ -131,18 +169,25 @@ Console.WriteLine(json.Set("ex1:7", "$", new { } })); ``` + #### Result + ```bash True ``` ## Read + ### Syntax + [JSON.GET](https://redis.io/commands/json.get/) ### Key Fetch + Set and Fetch a simple JSON KVP. + #### Command + ```c# json.Set("ex2:1", "$", "\"val\""); Console.WriteLine(json.Get(key: "ex2:1", @@ -151,7 +196,9 @@ Console.WriteLine(json.Get(key: "ex2:1", newLine: "\n" )); ``` + #### Result + ```bash [ "val" @@ -159,8 +206,11 @@ Console.WriteLine(json.Get(key: "ex2:1", ``` ### Single Property Fetch + Set and Fetch a single property from a JSON object. + #### Command + ```c# json.Set("ex2:2", "$", new { field1 = "val1" @@ -171,7 +221,9 @@ Console.WriteLine(json.Get(key: "ex2:2", newLine: "\n" )); ``` + #### Result + ```bash [ "val1" @@ -179,8 +231,11 @@ Console.WriteLine(json.Get(key: "ex2:2", ``` ### Multi-Property Fetch + Fetch multiple properties. + #### Command + ```c# json.Set("ex2:3", "$", new { field1 = "val1", @@ -192,7 +247,9 @@ Console.WriteLine(json.Get(key: "ex2:3", newLine: "\n" )); ``` + #### Result + ```bash { "$.field1":[ @@ -205,8 +262,11 @@ Console.WriteLine(json.Get(key: "ex2:3", ``` ### Nested Property Fetch + Fetch a property nested in another JSON object. + #### Command + ```c# json.Set("ex2:4", "$", new { obj1 = new { @@ -220,7 +280,9 @@ Console.WriteLine(json.Get(key: "ex2:4", newLine: "\n" )); ``` + #### Result + ```bash [ 2 @@ -228,8 +290,11 @@ Console.WriteLine(json.Get(key: "ex2:4", ``` ### Array Fetch + Fetch properties within an array and utilize array subscripting. + #### Command + ```c# json.Set("ex2:5", "$",new { str1 = "val1", @@ -261,7 +326,9 @@ Console.WriteLine(json.Get(key: "ex2:5", newLine: "\n" )); ``` + #### Results + ```bash [ [ @@ -284,12 +351,17 @@ Console.WriteLine(json.Get(key: "ex2:5", ``` ## Update + ### Syntax + [JSON.SET](https://redis.io/commands/json.set/) ### Entire Object + Update an entire JSON object. + #### Command + ```c# json.Set("ex3:1", "$", new {field1 = "val1"}); json.Set("ex3:1", "$", new {foo = "bar"}); @@ -298,7 +370,9 @@ Console.WriteLine(json.Get(key: "ex3:1", newLine: "\n" )); ``` + #### Result + ```bash { "foo":"bar" @@ -306,8 +380,11 @@ Console.WriteLine(json.Get(key: "ex3:1", ``` ### Single Property + Update a single property within an object. + #### Command + ```c# json.Set("ex3:2", "$", new { field1 = "val1", @@ -319,7 +396,9 @@ Console.WriteLine(json.Get(key: "ex3:2", newLine: "\n" )); ``` + #### Result + ```bash { "field1":"foo", @@ -328,8 +407,11 @@ Console.WriteLine(json.Get(key: "ex3:2", ``` ### Nested Property + Update a property in an embedded JSON object. + #### Command + ```c# json.Set("ex3:3", "$", new { obj1 = new { @@ -343,7 +425,9 @@ Console.WriteLine(json.Get(key: "ex3:3", newLine: "\n" )); ``` + #### Result + ```bash { "obj1":{ @@ -354,8 +438,11 @@ Console.WriteLine(json.Get(key: "ex3:3", ``` ### Array Item + Update an item in an array via index. + #### Command + ```c# json.Set("ex3:4", "$", new { arr1 = new[] {"val1", "val2", "val3"} @@ -366,7 +453,9 @@ Console.WriteLine(json.Get(key: "ex3:4", newLine: "\n" )); ``` + #### Result + ```bash { "arr1":[ @@ -378,12 +467,17 @@ Console.WriteLine(json.Get(key: "ex3:4", ``` ## Delete + ### Syntax + [JSON.DEL](https://redis.io/commands/json.del/) ### Entire object + Delete entire object/key. + #### Command + ```c# json.Set("ex4:1", "$", new {field1 = "val1"}); json.Del("ex4:1"); @@ -392,14 +486,19 @@ Console.WriteLine(json.Get(key: "ex4:1", newLine: "\n" )); ``` + #### Result + ```bash ``` ### Single Property + Delete a single property from an object. + #### Command + ```c# json.Set("ex4:2", "$", new { field1 = "val1", @@ -411,7 +510,9 @@ Console.WriteLine(json.Get(key: "ex4:2", newLine: "\n" )); ``` + #### Result + ```bash { "field2":"val2" @@ -419,8 +520,11 @@ Console.WriteLine(json.Get(key: "ex4:2", ``` ### Nested property + Delete a property from an embedded object. + #### Command + ```c# json.Set("ex4:3", "$", new { obj1 = new { @@ -434,7 +538,9 @@ Console.WriteLine(json.Get(key: "ex4:3", newLine: "\n" )); ``` + #### Result + ```bash { "obj1":{ @@ -444,8 +550,11 @@ Console.WriteLine(json.Get(key: "ex4:3", ``` ### Array item + Delete a single item from an array. + #### Command + ```c# json.Set("ex4:4", "$", new { arr1 = new[] {"val1", "val2", "val3"} @@ -456,7 +565,9 @@ Console.WriteLine(json.Get(key: "ex4:4", newLine: "\n" )); ``` + #### Result + ```bash { "arr1":[ @@ -464,4 +575,4 @@ Console.WriteLine(json.Get(key: "ex4:4", "val3" ] } -``` \ No newline at end of file +``` diff --git a/Examples/BasicQueryOperations.md b/Examples/BasicQueryOperations.md index 11e11ac6..fb18f982 100644 --- a/Examples/BasicQueryOperations.md +++ b/Examples/BasicQueryOperations.md @@ -1,28 +1,34 @@ # Basic Query Operations + Examples of simple query operations with RediSearch + ## Contents -1. [Business Value Statement](#value) -2. [Modules Needed](#modules) -3. [Data Set](#dataset) -4. [Data Loading](#loading) -5. [Index Creation](#index_creation) -6. [Search Examples](#search_examples) - 1. [Retrieve All](#retrieve_all) - 2. [Single Term Text](#single_term) - 3. [Exact Phrase Text](#exact_phrase) - 4. [Numeric Range](#numeric_range) - 5. [Tag Array](#tag_array) - 6. [Logical AND](#logical_and) - 7. [Logical OR](#logical_or) - 8. [Negation](#negation) - 9. [Prefix](#prefix) - 10. [Suffix](#suffix) - 11. [Fuzzy](#fuzzy) - 12. [Geo](#geo) + +1. [Business Value Statement](#value) +2. [Modules Needed](#modules) +3. [Data Set](#dataset) +4. [Data Loading](#loading) +5. [Index Creation](#index_creation) +6. [Search Examples](#search_examples) + 1. [Retrieve All](#retrieve_all) + 2. [Single Term Text](#single_term) + 3. [Exact Phrase Text](#exact_phrase) + 4. [Numeric Range](#numeric_range) + 5. [Tag Array](#tag_array) + 6. [Logical AND](#logical_and) + 7. [Logical OR](#logical_or) + 8. [Negation](#negation) + 9. [Prefix](#prefix) + 10. [Suffix](#suffix) + 11. [Fuzzy](#fuzzy) + 12. [Geo](#geo) ## Business Value Statement + Search is an essential function to derive the value of data. Redis provides inherent, high-speed search capabilities for JSON and Hash Set data. + ## Modules Needed + ```c# using StackExchange.Redis; using NRedisStack; @@ -32,6 +38,7 @@ using NRedisStack.Search.Literals.Enums; ``` ## Data Set + ```JSON [ { @@ -63,7 +70,9 @@ using NRedisStack.Search.Literals.Enums; } ] ``` + ## Data Loading + ```c# JsonCommands json = db.JSON(); json.Set("product:15970", "$", new { @@ -94,11 +103,15 @@ json.Set("product:46885", "$", new { coords = "-104.991531, 39.742043" }); ``` + ## Index Creation + ### Syntax + [FT.CREATE](https://redis.io/commands/ft.create/) #### Command + ```c# SearchCommands ft = db.FT(); try {ft.DropIndex("idx1");} catch {}; @@ -114,19 +127,26 @@ ft.Create("idx1", new FTCreateParams().On(IndexDataType.JSON) ``` ## Search Examples + ### Syntax + [FT.SEARCH](https://redis.io/commands/ft.search/) ### Retrieve All + Find all documents for a given index. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("*")).ToJson()) { Console.WriteLine(doc); } ``` + #### Result + ```json {"id":15970,"gender":"Men","season":["Fall","Winter"],"description":"Turtle Check Men Navy Blue Shirt","price":34.95,"city":"Boston","coords":"-71.057083, 42.361145"} {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} @@ -134,8 +154,11 @@ foreach (var doc in ft.Search("idx1", new Query("*")).ToJson()) ``` ### Single Term Text + Find all documents with a given word in a text field. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@description:Slippers")) .ToJson()) @@ -143,14 +166,19 @@ foreach (var doc in ft.Search("idx1", new Query("@description:Slippers")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} ``` ### Exact Phrase Text + Find all documents with a given phrase in a text field. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@description:(\"Blue Shirt\")")) .ToJson()) @@ -158,14 +186,19 @@ foreach (var doc in ft.Search("idx1", new Query("@description:(\"Blue Shirt\")") Console.WriteLine(doc); } ``` + #### Result + ```json {"id":15970,"gender":"Men","season":["Fall","Winter"],"description":"Turtle Check Men Navy Blue Shirt","price":34.95,"city":"Boston","coords":"-71.057083, 42.361145"} ``` ### Numeric Range + Find all documents with a numeric field in a given range. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@price:[40,130]")) .ToJson()) @@ -173,15 +206,20 @@ foreach (var doc in ft.Search("idx1", new Query("@price:[40,130]")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} {"id":59263,"gender":"Women","season":["Fall","Winter","Spring","Summer"],"description":"Titan Women Silver Watch","price":129.99,"city":"Dallas","coords":"-96.808891, 32.779167"} ``` ### Tag Array + Find all documents that contain a given value in an array field (tag). + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@season:{Spring}")) .ToJson()) @@ -189,14 +227,19 @@ foreach (var doc in ft.Search("idx1", new Query("@season:{Spring}")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":59263,"gender":"Women","season":["Fall","Winter","Spring","Summer"],"description":"Titan Women Silver Watch","price":129.99,"city":"Dallas","coords":"-96.808891, 32.779167"} ``` ### Logical AND + Find all documents contain both a numeric field in a range and a word in a text field. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@price:[40, 100] @description:Blue")) .ToJson()) @@ -204,14 +247,19 @@ foreach (var doc in ft.Search("idx1", new Query("@price:[40, 100] @description:B Console.WriteLine(doc); } ``` + #### Result + ```json {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} ``` ### Logical OR + Find all documents that either match tag value or text value. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("(@gender:{Women})|(@city:Boston)")) .ToJson()) @@ -219,15 +267,20 @@ foreach (var doc in ft.Search("idx1", new Query("(@gender:{Women})|(@city:Boston Console.WriteLine(doc); } ``` + #### Result + ```json {"id":15970,"gender":"Men","season":["Fall","Winter"],"description":"Turtle Check Men Navy Blue Shirt","price":34.95,"city":"Boston","coords":"-71.057083, 42.361145"} {"id":59263,"gender":"Women","season":["Fall","Winter","Spring","Summer"],"description":"Titan Women Silver Watch","price":129.99,"city":"Dallas","coords":"-96.808891, 32.779167"} ``` ### Negation + Find all documents that do not contain a given word in a text field. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("-(@description:Shirt)")) .ToJson()) @@ -235,15 +288,20 @@ foreach (var doc in ft.Search("idx1", new Query("-(@description:Shirt)")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} {"id":59263,"gender":"Women","season":["Fall","Winter","Spring","Summer"],"description":"Titan Women Silver Watch","price":129.99,"city":"Dallas","coords":"-96.808891, 32.779167"} ``` ### Prefix + Find all documents that have a word that begins with a given prefix value. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@description:Nav*")) .ToJson()) @@ -251,15 +309,20 @@ foreach (var doc in ft.Search("idx1", new Query("@description:Nav*")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":15970,"gender":"Men","season":["Fall","Winter"],"description":"Turtle Check Men Navy Blue Shirt","price":34.95,"city":"Boston","coords":"-71.057083, 42.361145"} {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} ``` ### Suffix + Find all documents that contain a word that ends with a given suffix value. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@description:*Watch")) .ToJson()) @@ -267,14 +330,19 @@ foreach (var doc in ft.Search("idx1", new Query("@description:*Watch")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":59263,"gender":"Women","season":["Fall","Winter","Spring","Summer"],"description":"Titan Women Silver Watch","price":129.99,"city":"Dallas","coords":"-96.808891, 32.779167"} ``` ### Fuzzy + Find all documents that contain a word that is within 1 Levenshtein distance of a given word. + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@description:%wavy%")) .ToJson()) @@ -282,16 +350,21 @@ foreach (var doc in ft.Search("idx1", new Query("@description:%wavy%")) Console.WriteLine(doc); } ``` + #### Result + ```json {"id":15970,"gender":"Men","season":["Fall","Winter"],"description":"Turtle Check Men Navy Blue Shirt","price":34.95,"city":"Boston","coords":"-71.057083, 42.361145"} {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} ``` ### Geo + Find all documents that have geographic coordinates within a given range of a given coordinate. Colorado Springs coords (long, lat) = -104.800644, 38.846127 + #### Command + ```c# foreach (var doc in ft.Search("idx1", new Query("@coords:[-104.800644 38.846127 100 mi]")) .ToJson()) @@ -299,7 +372,9 @@ foreach (var doc in ft.Search("idx1", new Query("@coords:[-104.800644 38.846127 Console.WriteLine(doc); } ``` + #### Result + ```json {"id":46885,"gender":"Boys","season":["Fall"],"description":"Ben 10 Boys Navy Blue Slippers","price":45.99,"city":"Denver","coords":"-104.991531, 39.742043"} -``` \ No newline at end of file +``` diff --git a/Examples/ConvertSearchResultToJson.md b/Examples/ConvertSearchResultToJson.md index 2d060e39..cfb58f85 100644 --- a/Examples/ConvertSearchResultToJson.md +++ b/Examples/ConvertSearchResultToJson.md @@ -1,31 +1,42 @@ # Converting Search Result to JSON -## This example shows how to convert Redis search results to JSON format using NRedisStack. + +## This example shows how to convert Redis search results to JSON format using NRedisStack Connect to the Redis server: + ```csharp var redis = ConnectionMultiplexer.Connect("localhost"); ``` + Get a reference to the database and for search and json commands: + ```csharp var db = redis.GetDatabase(); var ft = db.FT(); var json = db.JSON(); ``` + Create a search index with a JSON field: + ```csharp ft.Create("test", new FTCreateParams().On(IndexDataType.JSON).Prefix("doc:"), new Schema().AddTagField(new FieldName("$.name", "name"))); ``` + Insert 10 JSON documents into the index: + ```csharp for (int i = 0; i < 10; i++) { json.Set("doc:" + i, "$", "{\"name\":\"foo\"}"); } ``` + Execute a search query and convert the results to JSON: + ```csharp var res = ft.Search("test", new Query("@name:{foo}")); var docs = res.ToJson(); ``` -Now the `docs` variable contains a JSON list (IEnumerable) of the search results. \ No newline at end of file + +Now the `docs` variable contains a JSON list (IEnumerable) of the search results. diff --git a/Examples/HsetAndSearch.md b/Examples/HsetAndSearch.md index dec2f05c..54b35318 100644 --- a/Examples/HsetAndSearch.md +++ b/Examples/HsetAndSearch.md @@ -1,16 +1,22 @@ # HSET and Search + ## An example of mixing Redis open source command (HSET) with Redis Stack Redis commands (FT.CREATE & FT.SEARCH) Connect to the Redis server: + ```csharp var redis = ConnectionMultiplexer.Connect("localhost"); ``` + Get a reference to the database and for search commands: + ```csharp var db = redis.GetDatabase(); var ft = db.FT(); ``` + Use HSET to add a field-value pair to a hash: + ```csharp db.HashSet("profesor:5555", new HashEntry[] { new("first", "Albert"), new("last", "Blue"), new("age", "55") }); db.HashSet("student:1111", new HashEntry[] { new("first", "Joe"), new("last", "Dod"), new("age", "18") }); @@ -22,39 +28,53 @@ db.HashSet("teacher:6666", new HashEntry[] { new("first", "Pat"), new("last", "R ``` Create the schema indexing the text fields ```first``` and ```last```, and ```age``` as a numeric field: + ```csharp var schema = new Schema().AddTextField("first").AddTextField("last").AddNumericField("age"); ``` + Filter the index to only include hashes with an age greater than 16, and prefix of 'student:' or 'pupil:' + ```csharp var parameters = FTCreateParams.CreateParams().Filter("@age>16").Prefix("student:", "pupil:"); ``` + Create the index: + ```csharp ft.Create("example_index", parameters, schema); ``` -## Search Examples: + +## Search Examples Search all hashes in the index: + ```csharp var noFilters = ft.Search("example_index", new Query()); ``` + _noFilters_ now contains: _student:1111_, _student:5555_, _pupil:4444_, _student:3333_.

Search for hashes with a first name starting with Jo + ```csharp var startWithJo = ft.Search("example_index", new Query("@first:Jo*")); ``` + _startWithJo_ now contains: _student:1111_ (Joe), _student:5555_ (Joen).

Search for hashes with first name of Pat + ```csharp var namedPat = ft.Search("example_index", new Query("@first:Pat")); ``` + _namedPat_ now contains _pupil:4444_ (Pat). _teacher:6666_ (Pat) is not included because it does not have a prefix of 'student:' or 'pupil:'

Search for hashes with last name of Rod + ```csharp var lastNameRod = ft.Search("example_index", new Query("@last:Rod")); ``` + _lastNameRod_ is empty because there are no hashes with a last name of Rod that match the index definition. diff --git a/Examples/PipelineExample.md b/Examples/PipelineExample.md index 8b0e6ba9..66107426 100644 --- a/Examples/PipelineExample.md +++ b/Examples/PipelineExample.md @@ -1,48 +1,58 @@ # Pipeline + ## An example of pipelines Redis Stack Redis commands (JSON.SET & JSON.CLEAR & JSON.GET) Connect to the Redis server and Setup new Pipeline + ```csharp IDatabase db = redisFixture.Redis.GetDatabase(); var pipeline = new Pipeline(db); ``` - Add JSON data to pipeline + ```csharp pipeline.Json.SetAsync("person", "$", new { name = "John", age = 30, city = "New York", nicknames = new[] { "John", "Johny", "Jo" } }); ``` Increase age by 2 + ```csharp pipeline.Json.NumIncrbyAsync("person", "$.age", 2); ``` Remove the ```nicknames``` field from the JSON object + ```csharp pipeline.Json.ClearAsync("person", "$.nicknames"); ``` Delete the nicknames + ```csharp pipeline.Json.DelAsync("person", "$.nicknames"); ``` Retrieve the JSON response + ```csharp var getResponse = pipeline.Json.GetAsync("person"); ``` Execute pipeline + ```csharp pipeline.Execute(); ``` Access the result of the JSON response + ```csharp var result = getResponse.Result; ``` + now result is: + ```json { "name": "John", diff --git a/Examples/PipelineWithAsync.md b/Examples/PipelineWithAsync.md index 19e27d90..7cac09a1 100644 --- a/Examples/PipelineWithAsync.md +++ b/Examples/PipelineWithAsync.md @@ -1,17 +1,21 @@ # Pipeline With Async + ## An example of pipelines Redis Stack Redis commands (JSON.SET & JSON.CLEAR & JSON.GET) Connect to the Redis server + ```csharp var redis = ConnectionMultiplexer.Connect("localhost"); ``` Get a reference to the database + ```csharp var db = redis.GetDatabase(); ``` Setup pipeline connection + ```csharp var pipeline = new Pipeline(db); ``` @@ -62,11 +66,13 @@ pipeline.Execute(); ``` Get a reference to the database and for TimeSeries commands: + ```csharp var ts = db.TS(); ``` Get only the location label for each last sample, use SELECTED_LABELS. + ```csharp var respons = await ts.MGetAsync(new List { "temp=JLM" }, selectedLabels: new List { "location" }); ``` diff --git a/src/NRedisStack/Graph/ResultSet.cs b/src/NRedisStack/Graph/ResultSet.cs index 88618fcb..784c9b84 100644 --- a/src/NRedisStack/Graph/ResultSet.cs +++ b/src/NRedisStack/Graph/ResultSet.cs @@ -25,18 +25,18 @@ internal enum ResultSetScalarType VALUE_POINT } - private readonly RedisResult[] _rawResults; - private readonly GraphCache _graphCache; + private readonly RedisResult[]? _rawResults; + private readonly GraphCache? _graphCache; public Statistics Statistics { get; } - public Header Header { get; } + public Header? Header { get; } public int Count { get; } internal ResultSet(RedisResult result, GraphCache graphCache) { if (result.Type == ResultType.MultiBulk) { - var resultArray = (RedisResult[])result; + var resultArray = (RedisResult[])result!; ScanForErrors(resultArray); @@ -47,7 +47,7 @@ internal ResultSet(RedisResult result, GraphCache graphCache) Header = new Header(resultArray[0]); Statistics = ParseStatistics(resultArray[2]); - _rawResults = (RedisResult[])resultArray[1]; + _rawResults = (RedisResult[])resultArray[1]!; Count = _rawResults.Length; } @@ -73,14 +73,17 @@ internal ResultSet(RedisResult result, GraphCache graphCache) /// Get the enumerator for this result set. ///
/// + [Obsolete] public IEnumerator GetEnumerator() => RecordIterator().GetEnumerator(); /// /// Get the enumerator for this result set. /// /// + [Obsolete] IEnumerator IEnumerable.GetEnumerator() => RecordIterator().GetEnumerator(); + [Obsolete] private IEnumerable RecordIterator() { if (_rawResults == default) @@ -89,14 +92,14 @@ private IEnumerable RecordIterator() } else { - foreach (RedisResult[] row in _rawResults) + foreach (RedisResult[]? row in _rawResults) { - var parsedRow = new List(row.Length); + var parsedRow = new List(row!.Length); for (int i = 0; i < row.Length; i++) { - var obj = (RedisResult[])row[i]; - var objType = Header.SchemaTypes[i]; + var obj = (RedisResult[])row[i]!; + var objType = Header!.SchemaTypes[i]; switch (objType) { @@ -115,7 +118,7 @@ private IEnumerable RecordIterator() } } - yield return new Record(Header.SchemaNames, parsedRow); + yield return new Record(Header!.SchemaNames, parsedRow!); } yield break; diff --git a/src/NRedisStack/Json/JsonCommandBuilder.cs b/src/NRedisStack/Json/JsonCommandBuilder.cs index d5846a8a..c78845f0 100644 --- a/src/NRedisStack/Json/JsonCommandBuilder.cs +++ b/src/NRedisStack/Json/JsonCommandBuilder.cs @@ -16,7 +16,7 @@ public static SerializedCommand Resp(RedisKey key, string? path = null) return new SerializedCommand(JSON.RESP, key); } - return new SerializedCommand(JSON.RESP, key, path); + return new SerializedCommand(JSON.RESP, key, path!); } public static SerializedCommand Set(RedisKey key, RedisValue path, RedisValue json, When when = When.Always) diff --git a/src/NRedisStack/Json/JsonCommandsAsync.cs b/src/NRedisStack/Json/JsonCommandsAsync.cs index 2623b1b2..6ff742f8 100644 --- a/src/NRedisStack/Json/JsonCommandsAsync.cs +++ b/src/NRedisStack/Json/JsonCommandsAsync.cs @@ -97,7 +97,7 @@ public async Task GetAsync(RedisKey key, string[] paths, RedisValue public async Task> GetEnumerableAsync(RedisKey key, string path = "$") { RedisResult res = await _db.ExecuteAsync(JsonCommandBuilder.Get(key, path)); - return JsonSerializer.Deserialize>(res.ToString()); + return JsonSerializer.Deserialize>(res.ToString())!; } public async Task MGetAsync(RedisKey[] keys, string path) @@ -108,7 +108,7 @@ public async Task MGetAsync(RedisKey[] keys, string path) public async Task NumIncrbyAsync(RedisKey key, string path, double value) { var res = await _db.ExecuteAsync(JsonCommandBuilder.NumIncrby(key, path, value)); - return JsonSerializer.Deserialize(res.ToString()); + return JsonSerializer.Deserialize(res.ToString())!; } public async Task>> ObjKeysAsync(RedisKey key, string? path = null) diff --git a/src/NRedisStack/ResponseParser.cs b/src/NRedisStack/ResponseParser.cs index ce04d2de..4097b1f6 100644 --- a/src/NRedisStack/ResponseParser.cs +++ b/src/NRedisStack/ResponseParser.cs @@ -86,7 +86,7 @@ public static TimeStamp ToTimeStamp(this RedisResult result) public static IReadOnlyList ToTimeStampArray(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + RedisResult[] redisResults = (RedisResult[])result!; var list = new List(redisResults.Length); if (redisResults.Length == 0) return list; Array.ForEach(redisResults, timestamp => list.Add(ToTimeStamp(timestamp))); @@ -100,11 +100,11 @@ public static IReadOnlyList ToTimeStampArray(this RedisResult result) return new TimeSeriesTuple(ToTimeStamp(redisResults[0]), (double)redisResults[1]); } - public static Tuple ToScanDumpTuple(this RedisResult result) + public static Tuple? ToScanDumpTuple(this RedisResult result) { RedisResult[] redisResults = result.ToArray(); if (redisResults == null || redisResults.Length == 0) return null; - return new Tuple((long)redisResults[0], (Byte[])redisResults[1]); + return new Tuple((long)redisResults[0], (byte[])redisResults[1]!); } // TODO: check if this is needed: @@ -131,22 +131,22 @@ public static Tuple ToScanDumpTuple(this RedisResult result) public static IReadOnlyList ToTimeSeriesTupleArray(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + RedisResult[] redisResults = (RedisResult[])result!; var list = new List(redisResults.Length); if (redisResults.Length == 0) return list; - Array.ForEach(redisResults, tuple => list.Add(ToTimeSeriesTuple(tuple))); + Array.ForEach(redisResults, tuple => list.Add(ToTimeSeriesTuple(tuple)!)); return list; } public static IReadOnlyList ToLabelArray(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + RedisResult[] redisResults = (RedisResult[])result!; var list = new List(redisResults.Length); if (redisResults.Length == 0) return list; Array.ForEach(redisResults, labelResult => { - RedisResult[] labelTuple = (RedisResult[])labelResult; - list.Add(new TimeSeriesLabel((string)labelTuple[0], (string)labelTuple[1])); + var labelTuple = (RedisResult[])labelResult!; + list.Add(new TimeSeriesLabel(labelTuple[0].ToString(), labelTuple[1].ToString())); }); return list; } @@ -166,29 +166,29 @@ public static IReadOnlyList ToLabelArray(this RedisResult resul public static IReadOnlyList<(string key, IReadOnlyList labels, TimeSeriesTuple value)> ParseMGetResponse(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + var redisResults = (RedisResult[])result!; var list = new List<(string key, IReadOnlyList labels, TimeSeriesTuple values)>(redisResults.Length); if (redisResults.Length == 0) return list; Array.ForEach(redisResults, MRangeValue => { - RedisResult[] MRangeTuple = (RedisResult[])MRangeValue; - string key = (string)MRangeTuple[0]; + var MRangeTuple = (RedisResult[])MRangeValue!; + string key = MRangeTuple[0].ToString(); IReadOnlyList labels = ToLabelArray(MRangeTuple[1]); - TimeSeriesTuple value = ToTimeSeriesTuple(MRangeTuple[2]); - list.Add((key, labels, value)); + TimeSeriesTuple? value = ToTimeSeriesTuple(MRangeTuple[2]); + list.Add((key!, labels!, value!)); }); return list; } public static IReadOnlyList<(string key, IReadOnlyList labels, IReadOnlyList values)> ParseMRangeResponse(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + var redisResults = (RedisResult[])result!; var list = new List<(string key, IReadOnlyList labels, IReadOnlyList values)>(redisResults.Length); if (redisResults.Length == 0) return list; Array.ForEach(redisResults, MRangeValue => { - RedisResult[] MRangeTuple = (RedisResult[])MRangeValue; - string key = (string)MRangeTuple[0]; + var MRangeTuple = (RedisResult[])MRangeValue!; + string key = MRangeTuple[0].ToString(); IReadOnlyList labels = ToLabelArray(MRangeTuple[1]); IReadOnlyList values = ToTimeSeriesTupleArray(MRangeTuple[2]); list.Add((key, labels, values)); @@ -198,16 +198,16 @@ public static IReadOnlyList ToLabelArray(this RedisResult resul public static TimeSeriesRule ToRule(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; - string destKey = (string)redisResults[0]; + var redisResults = (RedisResult[])result!; + string destKey = redisResults[0].ToString(); long bucketTime = (long)redisResults[1]; - var aggregation = AggregationExtensions.AsAggregation((string)redisResults[2]); + var aggregation = AggregationExtensions.AsAggregation(redisResults[2].ToString()); return new TimeSeriesRule(destKey, bucketTime, aggregation); } public static IReadOnlyList ToRuleArray(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + var redisResults = (RedisResult[])result!; var list = new List(); if (redisResults.Length == 0) return list; Array.ForEach(redisResults, rule => list.Add(ToRule(rule))); @@ -216,7 +216,7 @@ public static IReadOnlyList ToRuleArray(this RedisResult result) public static TsDuplicatePolicy? ToPolicy(this RedisResult result) { - var policyStatus = (string)result; + var policyStatus = result.ToString(); if (String.IsNullOrEmpty(policyStatus) || policyStatus == "(nil)") { return null; @@ -419,6 +419,7 @@ public static IReadOnlyList ToRuleArray(this RedisResult result) mergedWeight, unmergedWeight, observations, totalCompressions, memoryUsage); } + [Obsolete] public static TimeSeriesInformation ToTimeSeriesInfo(this RedisResult result) { long totalSamples = -1, memoryUsage = -1, retentionTime = -1, chunkSize = -1, chunkCount = -1; @@ -428,10 +429,10 @@ public static TimeSeriesInformation ToTimeSeriesInfo(this RedisResult result) string? sourceKey = null, keySelfName = null; TsDuplicatePolicy? duplicatePolicy = null; IReadOnlyList? chunks = null; - RedisResult[] redisResults = (RedisResult[])result; + var redisResults = (RedisResult[])result!; for (int i = 0; i < redisResults.Length; ++i) { - string label = (string)redisResults[i++]; + string label = redisResults[i++].ToString(); switch (label) { case "totalSamples": @@ -464,7 +465,7 @@ public static TimeSeriesInformation ToTimeSeriesInfo(this RedisResult result) labels = ToLabelArray(redisResults[i]); break; case "sourceKey": - sourceKey = (string)redisResults[i]; + sourceKey = redisResults[i].ToString(); break; case "rules": rules = ToRuleArray(redisResults[i]); @@ -506,11 +507,11 @@ public static TimeSeriesInformation ToTimeSeriesInfo(this RedisResult result) public static Dictionary ToConfigDictionary(this RedisResult value) { - var res = (RedisResult[])value; + var res = (RedisResult[])value!; var dict = new Dictionary(); foreach (var pair in res) { - var arr = (RedisResult[])pair; + var arr = (RedisResult[])pair!; dict.Add(arr[0].ToString(), arr[1].ToString()); } return dict; @@ -518,7 +519,7 @@ public static Dictionary ToConfigDictionary(this RedisResult val public static IReadOnlyList ToTimeSeriesChunkArray(this RedisResult result) { - RedisResult[] redisResults = (RedisResult[])result; + var redisResults = (RedisResult[])result!; var list = new List(); if (redisResults.Length == 0) return list; Array.ForEach(redisResults, chunk => list.Add(ToTimeSeriesChunk(chunk))); @@ -529,10 +530,10 @@ public static TimeSeriesChunck ToTimeSeriesChunk(this RedisResult result) { long startTimestamp = -1, endTimestamp = -1, samples = -1, size = -1; string bytesPerSample = ""; - RedisResult[] redisResults = (RedisResult[])result; + var redisResults = (RedisResult[])result!; for (int i = 0; i < redisResults.Length; ++i) { - string label = (string)redisResults[i++]; + string label = redisResults[i++].ToString(); switch (label) { case "startTimestamp": @@ -564,7 +565,7 @@ public static List ToStringList(this RedisResult result) var list = new List(); if (redisResults.Length == 0) return list; - Array.ForEach(redisResults, str => list.Add((string)str)); + Array.ForEach(redisResults, str => list.Add(str.ToString())); return list; } diff --git a/src/NRedisStack/Search/Document.cs b/src/NRedisStack/Search/Document.cs index 3135621f..1b26b029 100644 --- a/src/NRedisStack/Search/Document.cs +++ b/src/NRedisStack/Search/Document.cs @@ -9,15 +9,15 @@ public class Document { public string Id { get; } public double Score { get; set; } - public byte[] Payload { get; } - public string[] ScoreExplained { get; private set; } // TODO: check if this is needed (Jedis does not have it) + public byte[]? Payload { get; } + public string[]? ScoreExplained { get; private set; } // TODO: check if this is needed (Jedis does not have it) internal readonly Dictionary _properties; public Document(string id, double score, byte[] payload) : this(id, null, score, payload) { } public Document(string id) : this(id, null, 1.0, null) { } public Document(string id, Dictionary fields, double score = 1.0) : this(id, fields, score, null) { } - public Document(string id, Dictionary fields, double score, byte[] payload) + public Document(string id, Dictionary? fields, double score, byte[]? payload) { Id = id; _properties = fields ?? new Dictionary(); @@ -34,7 +34,7 @@ public static Document Load(string id, double score, byte[] payload, RedisValue[ { for (int i = 0; i < fields.Length; i += 2) { - string fieldName = (string)fields[i]; + string fieldName = (string)fields[i]!; if (fieldName == "$") { ret["json"] = fields[i + 1]; @@ -48,7 +48,7 @@ public static Document Load(string id, double score, byte[] payload, RedisValue[ return ret; } - public static Document Load(string id, double score, byte[] payload, RedisValue[] fields, string[] scoreExplained) + public static Document Load(string id, double score, byte[]? payload, RedisValue[]? fields, string[]? scoreExplained) { Document ret = Document.Load(id, score, payload, fields); if (scoreExplained != null) diff --git a/src/NRedisStack/Search/FTCreateParams.cs b/src/NRedisStack/Search/FTCreateParams.cs index b06cffce..b10179af 100644 --- a/src/NRedisStack/Search/FTCreateParams.cs +++ b/src/NRedisStack/Search/FTCreateParams.cs @@ -4,21 +4,21 @@ namespace NRedisStack.Search { public class FTCreateParams { - private IndexDataType dataType; - private List prefixes; - private string filter; - private string language; - private string languageField; + private IndexDataType? dataType; + private List? prefixes; + private string? filter; + private string? language; + private string? languageField; private double score; - private string scoreField; - private string payloadField; + private string? scoreField; + private string? payloadField; private bool maxTextFields; private bool noOffsets; private long temporary; private bool noHL; private bool noFields; private bool noFreqs; - private List stopwords; + private List? stopwords; private bool skipInitialScan; public FTCreateParams() diff --git a/src/NRedisStack/Search/FieldName.cs b/src/NRedisStack/Search/FieldName.cs index 2ce9f850..b07d23f4 100644 --- a/src/NRedisStack/Search/FieldName.cs +++ b/src/NRedisStack/Search/FieldName.cs @@ -3,11 +3,11 @@ namespace NRedisStack.Search public class FieldName { private readonly string fieldName; - private string alias; + private string? alias; public FieldName(string name) : this(name, null) { } - public FieldName(string name, string attribute) + public FieldName(string name, string? attribute) { this.fieldName = name; this.alias = attribute; diff --git a/src/NRedisStack/Search/Query.cs b/src/NRedisStack/Search/Query.cs index b75fd184..5eafb572 100644 --- a/src/NRedisStack/Search/Query.cs +++ b/src/NRedisStack/Search/Query.cs @@ -153,29 +153,29 @@ public HighlightTags(string open, string close) /// /// Set the query language, for stemming purposes; see http://redisearch.io for documentation on languages and stemming /// - public string Language { get; set; } - - internal string[] _fields = null; - internal string[] _keys = null; - internal string[] _returnFields = null; - internal FieldName[] _returnFieldsNames = null; - internal string[] _highlightFields = null; - internal string[] _summarizeFields = null; - internal HighlightTags? _highlightTags = null; - internal string _summarizeSeparator = null; + public string? Language { get; set; } + + internal string[]? _fields; + internal string[]? _keys; + internal string[]? _returnFields; + internal FieldName[]? _returnFieldsNames; + internal string[]? _highlightFields; + internal string[]? _summarizeFields; + internal HighlightTags? _highlightTags; + internal string? _summarizeSeparator; internal int _summarizeNumFragments = -1, _summarizeFragmentLen = -1; /// /// Set the query payload to be evaluated by the scoring function /// - public string Payload { get; set; } // TODO: should this be a byte[]? + public string? Payload { get; set; } // TODO: should this be a byte[]? // TODO: Check if I need to add here WITHSORTKEYS /// /// Set the query parameter to sort by /// - public string SortBy { get; set; } + public string? SortBy { get; set; } /// /// Set the query parameter to sort by ASC by default @@ -188,7 +188,7 @@ public HighlightTags(string open, string close) /// /// Set the query scoring. see https://oss.redislabs.com/redisearch/Scoring.html for documentation /// - public string Scorer { get; set; } + public string? Scorer { get; set; } // public bool ExplainScore { get; set; } // TODO: Check if this is needed because Jedis doesn't have it private Dictionary _params = new Dictionary(); diff --git a/src/NRedisStack/Search/SearchResult.cs b/src/NRedisStack/Search/SearchResult.cs index d42bf33b..1d75ffd1 100644 --- a/src/NRedisStack/Search/SearchResult.cs +++ b/src/NRedisStack/Search/SearchResult.cs @@ -50,11 +50,11 @@ internal SearchResult(RedisResult[] resp, bool hasContent, bool hasScores, bool Documents = docs; for (int i = 1; i < resp.Length; i += step) { - var id = (string)resp[i]; + var id = resp[i].ToString(); double score = 1.0; - byte[] payload = null; - RedisValue[] fields = null; - string[] scoreExplained = null; + byte[]? payload = null; + RedisValue[]? fields = null; + string[]? scoreExplained = null; if (hasScores) { // if (shouldExplainScore) @@ -71,12 +71,12 @@ internal SearchResult(RedisResult[] resp, bool hasContent, bool hasScores, bool } if (hasPayloads) { - payload = (byte[])resp[i + payloadOffset]; + payload = (byte[]?)resp[i + payloadOffset]; } if (hasContent) { - fields = (RedisValue[])resp[i + contentOffset]; + fields = (RedisValue[]?)resp[i + contentOffset]; } docs.Add(Document.Load(id, score, payload, fields, scoreExplained)); diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs index e88de817..3478c25a 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesInformation.cs @@ -22,12 +22,12 @@ public class TimeSeriesInformation /// /// First timestamp present in the time-series. /// - public TimeStamp FirstTimeStamp { get; private set; } + public TimeStamp? FirstTimeStamp { get; private set; } /// /// Last timestamp present in the time-series. /// - public TimeStamp LastTimeStamp { get; private set; } + public TimeStamp? LastTimeStamp { get; private set; } /// /// Retention time, in milliseconds, for the time-series. @@ -53,17 +53,17 @@ public class TimeSeriesInformation /// /// A readonly list of TimeSeriesLabel that represent metadata labels of the time-series. /// - public IReadOnlyList Labels { get; private set; } + public IReadOnlyList? Labels { get; private set; } /// /// Source key for the queries time series key. /// - public string SourceKey { get; private set; } + public string? SourceKey { get; private set; } /// /// A readonly list of TimeSeriesRules that represent compaction Rules of the time-series. /// - public IReadOnlyList Rules { get; private set; } + public IReadOnlyList? Rules { get; private set; } /// /// The policy will define handling of duplicate samples. @@ -79,10 +79,12 @@ public class TimeSeriesInformation /// In DEBUG mode: gives more information about the chunks /// public IReadOnlyList? Chunks { get; private set; } + + [Obsolete] internal TimeSeriesInformation(long totalSamples, long memoryUsage, - TimeStamp firstTimeStamp, TimeStamp lastTimeStamp, long retentionTime, - long chunkCount, long chunkSize, IReadOnlyList labels, - string sourceKey, IReadOnlyList rules, TsDuplicatePolicy? policy, + TimeStamp? firstTimeStamp, TimeStamp? lastTimeStamp, long retentionTime, + long chunkCount, long chunkSize, IReadOnlyList? labels, + string? sourceKey, IReadOnlyList? rules, TsDuplicatePolicy? policy, string? keySelfName = null, IReadOnlyList? chunks = null) { TotalSamples = totalSamples; diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 58b65efe..6b12db66 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -305,7 +305,7 @@ public void TestRecord() Assert.NotNull(stats.QueryInternalExecutionTime); Assert.NotEmpty(stats.QueryInternalExecutionTime); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // IReadOnlyCollection iterator = resultSet.GetEnumerator(); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); @@ -394,7 +394,7 @@ public void TestAdditionToProcedures() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); var record = iterator.Current; @@ -427,7 +427,7 @@ public void TestAdditionToProcedures() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -496,11 +496,11 @@ public void TestArraySupport() List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -518,11 +518,11 @@ public void TestArraySupport() schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -541,7 +541,7 @@ record = iterator.Current; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record @@ -618,7 +618,7 @@ public void TestNullGraphEntities() Assert.NotNull(graph.Query("social", "CREATE (:L)-[:E]->(:L2)")); // Test a query that produces 1 record with 3 null values. ResultSet resultSet = graph.Query("social", "OPTIONAL MATCH (a:NONEXISTENT)-[e]->(b) RETURN a, e, b"); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); IEnumerator iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -672,7 +672,7 @@ public void Test64BitNumber() Dictionary parameters = new Dictionary(); parameters.Add("val", value); ResultSet resultSet = graph.Query("social", "CREATE (n {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; // Assert.Equal(value, r.Values[0]); @@ -692,7 +692,7 @@ public void TestCachedExecution() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = graph.Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; Assert.Equal(parameters["val"], resultSet.First().Values[0]); Assert.False(resultSet.Statistics.CachedExecution); @@ -703,7 +703,7 @@ public void TestCachedExecution() { resultSet = graph.Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // r = resultSet.GetEnumerator().Current; // Assert.Equal(parameters["val"], r.Values[0]); Assert.Equal(parameters["val"], resultSet.First().Values[0]); @@ -732,7 +732,7 @@ public void TestMapDataType() f.Add("y", (long)2); expected.Add("f", f); ResultSet res = graph.Query("social", "RETURN {a:1, b:'str', c:NULL, d:[1,2,3], e:True, f:{x:1, y:2}}"); - Assert.Equal(1, res.Count); + Assert.Single(res); var iterator = res.GetEnumerator(); iterator.MoveNext(); @@ -772,7 +772,7 @@ public void TestGeoPointLonLat() private void AssertTestGeoPoint(IGraphCommands graph) { ResultSet results = graph.Query("social", "MATCH (restaurant) RETURN restaurant"); - Assert.Equal(1, results.Count); + Assert.Single(results); var record = results.GetEnumerator(); record.MoveNext(); Assert.Equal(1, record.Current.Size); @@ -803,7 +803,7 @@ public void timeoutArgument() db.Execute("FLUSHALL"); var graph = db.GRAPH(); ResultSet rs = graph.Query("social", "UNWIND range(0,100) AS x WITH x AS x WHERE x = 100 RETURN x", 1L); - Assert.Equal(1, rs.Count); + Assert.Single(rs); var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -822,7 +822,7 @@ public void TestCachedExecutionReadOnly() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = graph.RO_Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); iterator.MoveNext(); NRedisStack.Graph.Record r = iterator.Current; @@ -835,7 +835,7 @@ public void TestCachedExecutionReadOnly() { resultSet = graph.RO_Query("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); iterator.MoveNext(); r = iterator.Current; @@ -851,7 +851,7 @@ public void TestSimpleReadOnly() var graph = db.GRAPH(); graph.Query("social", "CREATE (:person{name:'filipe',age:30})"); ResultSet rsRo = graph.RO_Query("social", "MATCH (a:person) WHERE (a.name = 'filipe') RETURN a.age"); - Assert.Equal(1, rsRo.Count); + Assert.Single(rsRo); var iterator = rsRo.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -936,7 +936,7 @@ public void TestConfig() Assert.True(graph.ConfigSet(name, 250L)); var actual = graph.ConfigGet(name); - Assert.Equal(1, actual.Count); + Assert.Single(actual); Assert.Equal("250", actual[name].ToString()); graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); @@ -1291,7 +1291,7 @@ await graph.QueryAsync("social", "MATCH (a:person), (b:person) WHERE (a.name = ' Assert.NotNull(stats.QueryInternalExecutionTime); Assert.NotEmpty(stats.QueryInternalExecutionTime); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // IReadOnlyCollection iterator = resultSet.GetEnumerator(); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); @@ -1380,7 +1380,7 @@ public async Task TestAdditionToProceduresAsync() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); var record = iterator.Current; @@ -1413,7 +1413,7 @@ public async Task TestAdditionToProceduresAsync() Assert.Equal(2, schemaNames.Count); Assert.Equal("a", schemaNames[0]); Assert.Equal("r", schemaNames[1]); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -1482,11 +1482,11 @@ public async Task TestArraySupportAsync() List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -1504,11 +1504,11 @@ public async Task TestArraySupportAsync() schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); record = iterator.Current; @@ -1527,7 +1527,7 @@ record = iterator.Current; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); - Assert.Equal(1, schemaNames.Count); + Assert.Single(schemaNames); Assert.Equal("x", schemaNames[0]); // check record @@ -1604,7 +1604,7 @@ public async Task TestNullGraphEntitiesAsync() Assert.NotNull(await graph.QueryAsync("social", "CREATE (:L)-[:E]->(:L2)")); // Test a query that produces 1 record with 3 null values. ResultSet resultSet = await graph.QueryAsync("social", "OPTIONAL MATCH (a:NONEXISTENT)-[e]->(b) RETURN a, e, b"); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); IEnumerator iterator = resultSet.GetEnumerator(); Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; @@ -1658,7 +1658,7 @@ public async Task Test64bitnumberAsync() Dictionary parameters = new Dictionary(); parameters.Add("val", value); ResultSet resultSet = await graph.QueryAsync("social", "CREATE (n {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; // Assert.Equal(value, r.Values[0]); @@ -1678,7 +1678,7 @@ public async Task TestCachedExecutionAsync() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = await graph.QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // NRedisStack.Graph.Record r = resultSet.GetEnumerator().Current; Assert.Equal(parameters["val"], resultSet.First().Values[0]); Assert.False(resultSet.Statistics.CachedExecution); @@ -1689,7 +1689,7 @@ public async Task TestCachedExecutionAsync() { resultSet = await graph.QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); // r = resultSet.GetEnumerator().Current; // Assert.Equal(parameters["val"], r.Values[0]); Assert.Equal(parameters["val"], resultSet.First().Values[0]); @@ -1718,7 +1718,7 @@ public async Task TestMapDataTypeAsync() f.Add("y", (long)2); expected.Add("f", f); ResultSet res = await graph.QueryAsync("social", "RETURN {a:1, b:'str', c:NULL, d:[1,2,3], e:True, f:{x:1, y:2}}"); - Assert.Equal(1, res.Count); + Assert.Single(res); var iterator = res.GetEnumerator(); iterator.MoveNext(); @@ -1758,7 +1758,7 @@ public async Task TestGeoPointLonLatAsync() private async Task AssertTestGeoPointAsync(GraphCommands graph) { ResultSet results = await graph.QueryAsync("social", "MATCH (restaurant) RETURN restaurant"); - Assert.Equal(1, results.Count); + Assert.Single(results); var record = results.GetEnumerator(); record.MoveNext(); Assert.Equal(1, record.Current.Size); @@ -1776,7 +1776,7 @@ public async Task timeoutArgumentAsync() db.Execute("FLUSHALL"); var graph = db.GRAPH(); ResultSet rs = await graph.QueryAsync("social", "UNWIND range(0,100) AS x WITH x AS x WHERE x = 100 RETURN x", 1L); - Assert.Equal(1, rs.Count); + Assert.Single(rs); var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -1795,7 +1795,7 @@ public async Task TestCachedExecutionReadOnlyAsync() Dictionary parameters = new Dictionary(); parameters.Add("val", 1L); ResultSet resultSet = await graph.RO_QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); var iterator = resultSet.GetEnumerator(); iterator.MoveNext(); NRedisStack.Graph.Record r = iterator.Current; @@ -1808,7 +1808,7 @@ public async Task TestCachedExecutionReadOnlyAsync() { resultSet = await graph.RO_QueryAsync("social", "MATCH (n:N {val:$val}) RETURN n.val", parameters); } - Assert.Equal(1, resultSet.Count); + Assert.Single(resultSet); iterator = resultSet.GetEnumerator(); iterator.MoveNext(); r = iterator.Current; @@ -1824,7 +1824,7 @@ public async Task TestSimpleReadOnlyAsync() var graph = db.GRAPH(); await graph.QueryAsync("social", "CREATE (:person{name:'filipe',age:30})"); ResultSet rsRo = await graph.RO_QueryAsync("social", "MATCH (a:person) WHERE (a.name = 'filipe') RETURN a.age"); - Assert.Equal(1, rsRo.Count); + Assert.Single(rsRo); var iterator = rsRo.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; @@ -1909,7 +1909,7 @@ public async Task TestConfigAsync() Assert.True(await graph.ConfigSetAsync(name, 250L)); var actual = await graph.ConfigGetAsync(name); - Assert.Equal(1, actual.Count); + Assert.Single(actual); Assert.Equal("250", actual[name].ToString()); await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); @@ -1977,7 +1977,7 @@ public void TestParseInfinity() db.Execute("FLUSHALL"); var graph = db.GRAPH(); ResultSet rs = graph.Query("db", "RETURN 10^100000"); - Assert.Equal(1, rs.Count()); + Assert.Single(rs); var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 5caf53b5..3be95e78 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -2256,7 +2256,7 @@ public void TestBasicSpellCheck() db.HashSet("doc1", new HashEntry[] { new HashEntry("name", "name2"), new HashEntry("body", "name2") }); var reply = ft.SpellCheck(index, "name"); - Assert.Equal(1, reply.Keys.Count); + Assert.Single(reply.Keys); Assert.Equal("name", reply.Keys.First()); Assert.Equal(1, reply["name"]["name1"]); Assert.Equal(2, reply["name"]["name2"]); @@ -2276,7 +2276,7 @@ public async Task TestBasicSpellCheckAsync() db.HashSet("doc1", new HashEntry[] { new HashEntry("name", "name2"), new HashEntry("body", "name2") }); var reply = await ft.SpellCheckAsync(index, "name"); - Assert.Equal(1, reply.Keys.Count); + Assert.Single(reply.Keys); Assert.Equal("name", reply.Keys.First()); Assert.Equal(1, reply["name"]["name1"]); Assert.Equal(2, reply["name"]["name2"]); @@ -2422,13 +2422,13 @@ public void TestAddAndGetSuggestion() Assert.True(ft.SugAdd(key, noMatch, 1d) > 0); // test that with a partial part of that string will have the entire word returned - Assert.Equal(1, ft.SugGet(key, suggestion.Substring(0, 3), true, max: 5).Count); + Assert.Single(ft.SugGet(key, suggestion.Substring(0, 3), true, max: 5)); // turn off fuzzy start at second word no hit Assert.Empty(ft.SugGet(key, noMatch.Substring(1, 6), false, max: 5)); // my attempt to trigger the fuzzy by 1 character - Assert.Equal(1, ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5).Count); + Assert.Single(ft.SugGet(key, noMatch.Substring(1, 6), true, max: 5)); } [Fact] @@ -2445,13 +2445,13 @@ public async Task TestAddAndGetSuggestionAsync() Assert.True(await ft.SugAddAsync(key, noMatch, 1d) > 0); // test that with a partial part of that string will have the entire word returned - Assert.Equal(1, (await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5)).Count); + Assert.Single((await ft.SugGetAsync(key, suggestion.Substring(0, 3), true, max: 5))); // turn off fuzzy start at second word no hit Assert.Empty((await ft.SugGetAsync(key, noMatch.Substring(1, 6), false, max: 5))); // my attempt to trigger the fuzzy by 1 character - Assert.Equal(1, (await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5)).Count); + Assert.Single((await ft.SugGetAsync(key, noMatch.Substring(1, 6), true, max: 5))); } [Fact] From e95f68cae5ff1bba80a99482fd9d14f1bee368e6 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 13:29:23 +0300 Subject: [PATCH 36/48] dataType not nullable --- src/NRedisStack/Search/FTCreateParams.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NRedisStack/Search/FTCreateParams.cs b/src/NRedisStack/Search/FTCreateParams.cs index b10179af..9ae3e4f4 100644 --- a/src/NRedisStack/Search/FTCreateParams.cs +++ b/src/NRedisStack/Search/FTCreateParams.cs @@ -4,7 +4,7 @@ namespace NRedisStack.Search { public class FTCreateParams { - private IndexDataType? dataType; + private IndexDataType dataType; private List? prefixes; private string? filter; private string? language; From 0c0910e0e8db4bb7e5f33575dbc966118b48f367 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 15:26:23 +0300 Subject: [PATCH 37/48] cleaning --- src/NRedisStack/Json/JsonCommandsAsync.cs | 4 +- .../TimeSeries/ITimeSeriesCommands.cs | 4 +- .../TimeSeries/ITimeSeriesCommandsAsync.cs | 4 +- .../CuckooFilter/CuckooTests.cs | 6 +-- tests/NRedisStack.Tests/PipelineTests.cs | 46 +++++++++---------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/NRedisStack/Json/JsonCommandsAsync.cs b/src/NRedisStack/Json/JsonCommandsAsync.cs index 6ff742f8..a4d12639 100644 --- a/src/NRedisStack/Json/JsonCommandsAsync.cs +++ b/src/NRedisStack/Json/JsonCommandsAsync.cs @@ -97,7 +97,7 @@ public async Task GetAsync(RedisKey key, string[] paths, RedisValue public async Task> GetEnumerableAsync(RedisKey key, string path = "$") { RedisResult res = await _db.ExecuteAsync(JsonCommandBuilder.Get(key, path)); - return JsonSerializer.Deserialize>(res.ToString())!; + return JsonSerializer.Deserialize>(res.ToString()!)!; } public async Task MGetAsync(RedisKey[] keys, string path) @@ -108,7 +108,7 @@ public async Task MGetAsync(RedisKey[] keys, string path) public async Task NumIncrbyAsync(RedisKey key, string path, double value) { var res = await _db.ExecuteAsync(JsonCommandBuilder.NumIncrby(key, path, value)); - return JsonSerializer.Deserialize(res.ToString())!; + return JsonSerializer.Deserialize(res.ToString()!)!; } public async Task>> ObjKeysAsync(RedisKey key, string? path = null) diff --git a/src/NRedisStack/TimeSeries/ITimeSeriesCommands.cs b/src/NRedisStack/TimeSeries/ITimeSeriesCommands.cs index e9c13abf..8caec91f 100644 --- a/src/NRedisStack/TimeSeries/ITimeSeriesCommands.cs +++ b/src/NRedisStack/TimeSeries/ITimeSeriesCommands.cs @@ -18,7 +18,7 @@ public interface ITimeSeriesCommands /// Optinal: Define handling of duplicate samples behavior (avalible for RedisTimeseries >= 1.4) /// If the operation executed successfully /// - bool Create(string key, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); + bool Create(string key, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); #endregion @@ -52,7 +52,7 @@ public interface ITimeSeriesCommands /// The timestamp value of the new sample /// TimeStamp Add(string key, TimeStamp timestamp, double value, long? retentionTime = null, - IReadOnlyCollection labels = null, bool? uncompressed = null, + IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); /// diff --git a/src/NRedisStack/TimeSeries/ITimeSeriesCommandsAsync.cs b/src/NRedisStack/TimeSeries/ITimeSeriesCommandsAsync.cs index 57b0ca7e..dfd46657 100644 --- a/src/NRedisStack/TimeSeries/ITimeSeriesCommandsAsync.cs +++ b/src/NRedisStack/TimeSeries/ITimeSeriesCommandsAsync.cs @@ -18,7 +18,7 @@ public interface ITimeSeriesCommandsAsync /// Optinal: Define handling of duplicate samples behavior (avalible for RedisTimeseries >= 1.4) /// If the operation executed successfully /// - Task CreateAsync(string key, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); + Task CreateAsync(string key, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); #endregion @@ -51,7 +51,7 @@ public interface ITimeSeriesCommandsAsync /// Optioal: overwrite key and database configuration for DUPLICATE_POLICY /// The timestamp value of the new sample /// - Task AddAsync(string key, TimeStamp timestamp, double value, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); + Task AddAsync(string key, TimeStamp timestamp, double value, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null); /// /// Append new samples to multiple series. diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 4a63bdf0..936217ed 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -35,7 +35,7 @@ public async Task TestReserveBasicAsync() db.Execute("FLUSHALL"); var cf = db.CF(); Assert.True(await cf.ReserveAsync(key, 100L, maxIterations: 20, expansion: 1)); - Assert.ThrowsAsync(async () => await cf.ReserveAsync(key, 100L)); + _ = Assert.ThrowsAsync(async () => await cf.ReserveAsync(key, 100L)); Assert.True(await (cf.AddAsync(key, "item1"))); Assert.True(await cf.ExistsAsync(key, "item1")); @@ -297,7 +297,7 @@ public async Task TestInsertNXAsync() RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; - Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, items, 1024, true)); + _ = Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, items, 1024, true)); var result = await cf.InsertNXAsync(key, items, 1024); await cf.InsertNXAsync(key, items, 10245, true); var trues = new bool[] { true, true, true }; @@ -313,7 +313,7 @@ public async Task TestInsertNXAsync() Assert.Equal(result, new bool[] { false, false, false }); // test empty items: - Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[] { })); + _ = Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[] { })); } [Fact] diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 592dcfce..4142ebab 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -23,16 +23,16 @@ public async Task TestModulsPipeline() db.Execute("FLUSHALL"); var pipeline = new Pipeline(db); - pipeline.Bf.ReserveAsync("bf-key", 0.001, 100); - pipeline.Bf.AddAsync("bf-key", "1"); - pipeline.Cms.InitByDimAsync("cms-key", 100, 5); - pipeline.Cf.ReserveAsync("cf-key", 100); - pipeline.Graph.QueryAsync("graph-key", "CREATE ({name:'shachar',age:23})"); - pipeline.Json.SetAsync("json-key", "$", "{}"); - pipeline.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); - pipeline.Tdigest.CreateAsync("tdigest-key", 100); - pipeline.Ts.CreateAsync("ts-key", 100); - pipeline.TopK.ReserveAsync("topk-key", 100, 100, 100); + _ = pipeline.Bf.ReserveAsync("bf-key", 0.001, 100); + _ = pipeline.Bf.AddAsync("bf-key", "1"); + _ = pipeline.Cms.InitByDimAsync("cms-key", 100, 5); + _ = pipeline.Cf.ReserveAsync("cf-key", 100); + _ = pipeline.Graph.QueryAsync("graph-key", "CREATE ({name:'shachar',age:23})"); + _ = pipeline.Json.SetAsync("json-key", "$", "{}"); + _ = pipeline.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); + _ = pipeline.Tdigest.CreateAsync("tdigest-key", 100); + _ = pipeline.Ts.CreateAsync("ts-key", 100); + _ = pipeline.TopK.ReserveAsync("topk-key", 100, 100, 100); Assert.False(db.KeyExists("bf-key")); Assert.False(db.KeyExists("cms-key")); @@ -51,13 +51,13 @@ public async Task TestModulsPipeline() Assert.True(db.KeyExists("cf-key")); Assert.True(db.KeyExists("graph-key")); Assert.True(db.KeyExists("json-key")); - Assert.True(db.FT()._List().Length == 1); + Assert.Equal(1, db.FT()._List().Length); Assert.True(db.KeyExists("tdigest-key")); Assert.True(db.KeyExists("ts-key")); Assert.True(db.KeyExists("topk-key")); Assert.True(db.BF().Exists("bf-key", "1")); - Assert.True(db.CMS().Info("cms-key").Width == 100); + Assert.Equal(100, db.CMS().Info("cms-key").Width); Assert.True(db.CF().Info("cf-key").Size > 0); Assert.True(db.GRAPH().List().Count > 0); Assert.False(db.JSON().Get("json-key").IsNull); @@ -74,15 +74,15 @@ public async Task TestModulsPipelineWithotGraph() db.Execute("FLUSHALL"); var pipeline = new Pipeline(db); - pipeline.Bf.ReserveAsync("bf-key", 0.001, 100); - pipeline.Bf.AddAsync("bf-key", "1"); - pipeline.Cms.InitByDimAsync("cms-key", 100, 5); - pipeline.Cf.ReserveAsync("cf-key", 100); - pipeline.Json.SetAsync("json-key", "$", "{}"); - pipeline.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); - pipeline.Tdigest.CreateAsync("tdigest-key", 100); - pipeline.Ts.CreateAsync("ts-key", 100); - pipeline.TopK.ReserveAsync("topk-key", 100, 100, 100); + _ = pipeline.Bf.ReserveAsync("bf-key", 0.001, 100); + _ = pipeline.Bf.AddAsync("bf-key", "1"); + _ = pipeline.Cms.InitByDimAsync("cms-key", 100, 5); + _ = pipeline.Cf.ReserveAsync("cf-key", 100); + _ = pipeline.Json.SetAsync("json-key", "$", "{}"); + _ = pipeline.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); + _ = pipeline.Tdigest.CreateAsync("tdigest-key", 100); + _ = pipeline.Ts.CreateAsync("ts-key", 100); + _ = pipeline.TopK.ReserveAsync("topk-key", 100, 100, 100); Assert.False(db.KeyExists("bf-key")); Assert.False(db.KeyExists("cms-key")); @@ -99,13 +99,13 @@ public async Task TestModulsPipelineWithotGraph() Assert.True(db.KeyExists("cms-key")); Assert.True(db.KeyExists("cf-key")); Assert.True(db.KeyExists("json-key")); - Assert.True(db.FT()._List().Length == 1); + Assert.Equal(1, db.FT()._List().Length); Assert.True(db.KeyExists("tdigest-key")); Assert.True(db.KeyExists("ts-key")); Assert.True(db.KeyExists("topk-key")); Assert.True(db.BF().Exists("bf-key", "1")); - Assert.True(db.CMS().Info("cms-key").Width == 100); + Assert.Equal(100, db.CMS().Info("cms-key").Width); Assert.True(db.CF().Info("cf-key").Size > 0); Assert.False(db.JSON().Get("json-key").IsNull); Assert.NotNull(db.FT().Info("ft-key")); From af1b585ad6ff45a80a8877ad9e580a746c4b3f1d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 15:34:35 +0300 Subject: [PATCH 38/48] TS warnings --- .config/dotnet-tools.json | 12 ++++++++++++ src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs | 2 +- src/NRedisStack/TimeSeries/TimeSeriesAux.cs | 6 +++--- src/NRedisStack/TimeSeries/TimeSeriesCommands.cs | 5 +++-- .../TimeSeries/TimeSeriesCommandsAsync.cs | 5 +++-- 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..ef84a272 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "csharpier": { + "version": "0.25.0", + "commands": [ + "dotnet-csharpier" + ] + } + } +} \ No newline at end of file diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs index 1dfe3e76..cf523060 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs @@ -64,7 +64,7 @@ public static implicit operator long(TimeStamp ts) => /// Implicit cast from TimeStamp to string. /// /// TimeStamp - public static implicit operator string(TimeStamp ts) => ts.Value.ToString(); + public static implicit operator string? (TimeStamp ts) => ts.Value.ToString(); /// /// Implicit cast from DateTime to TimeStamp. diff --git a/src/NRedisStack/TimeSeries/TimeSeriesAux.cs b/src/NRedisStack/TimeSeries/TimeSeriesAux.cs index 9a0a0291..b7dfb289 100644 --- a/src/NRedisStack/TimeSeries/TimeSeriesAux.cs +++ b/src/NRedisStack/TimeSeries/TimeSeriesAux.cs @@ -30,7 +30,7 @@ public static void AddChunkSize(this IList args, long? chunkSize) } } - public static void AddLabels(this IList args, IReadOnlyCollection labels) + public static void AddLabels(this IList args, IReadOnlyCollection? labels) { if (labels != null) { @@ -215,7 +215,7 @@ public static void AddRule(this IList args, TimeSeriesRule rule) args.Add(rule.TimeBucket); } - public static List BuildTsCreateArgs(string key, long? retentionTime, IReadOnlyCollection labels, bool? uncompressed, + public static List BuildTsCreateArgs(string key, long? retentionTime, IReadOnlyCollection? labels, bool? uncompressed, long? chunkSizeBytes, TsDuplicatePolicy? policy) { var args = new List { key }; @@ -239,7 +239,7 @@ public static List BuildTsAlterArgs(string key, long? retentionTime, lon } public static List BuildTsAddArgs(string key, TimeStamp timestamp, double value, long? retentionTime, - IReadOnlyCollection labels, bool? uncompressed, long? chunkSizeBytes, TsDuplicatePolicy? policy) + IReadOnlyCollection? labels, bool? uncompressed, long? chunkSizeBytes, TsDuplicatePolicy? policy) { var args = new List { key, timestamp.Value, value }; args.AddRetentionTime(retentionTime); diff --git a/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs b/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs index b6566fa1..efbeb31f 100644 --- a/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs +++ b/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs @@ -14,7 +14,7 @@ public TimeSeriesCommands(IDatabase db) : base(db) #region Create /// - public bool Create(string key, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) + public bool Create(string key, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) { return _db.Execute(TimeSeriesCommandsBuilder.Create(key, retentionTime, labels, uncompressed, chunkSizeBytes, @@ -34,7 +34,7 @@ public bool Alter(string key, long? retentionTime = null, long? chunkSizeBytes = /// public TimeStamp Add(string key, TimeStamp timestamp, double value, long? retentionTime = null, - IReadOnlyCollection labels = null, bool? uncompressed = null, + IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) { return _db.Execute(TimeSeriesCommandsBuilder.Add(key, timestamp, value, retentionTime, labels, @@ -195,6 +195,7 @@ public IReadOnlyList RevRange(string key, #region General /// + [Obsolete] public TimeSeriesInformation Info(string key, bool debug = false) { return _db.Execute(TimeSeriesCommandsBuilder.Info(key, debug)).ToTimeSeriesInfo(); diff --git a/src/NRedisStack/TimeSeries/TimeSeriesCommandsAsync.cs b/src/NRedisStack/TimeSeries/TimeSeriesCommandsAsync.cs index ede7f288..3a7e1a4b 100644 --- a/src/NRedisStack/TimeSeries/TimeSeriesCommandsAsync.cs +++ b/src/NRedisStack/TimeSeries/TimeSeriesCommandsAsync.cs @@ -14,7 +14,7 @@ public TimeSeriesCommandsAsync(IDatabaseAsync db) #region Create /// - public async Task CreateAsync(string key, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) + public async Task CreateAsync(string key, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) { return (await _db.ExecuteAsync(TimeSeriesCommandsBuilder.Create(key, retentionTime, labels, uncompressed, chunkSizeBytes, @@ -32,7 +32,7 @@ public async Task AlterAsync(string key, long? retentionTime = null, long? } /// - public async Task AddAsync(string key, TimeStamp timestamp, double value, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) + public async Task AddAsync(string key, TimeStamp timestamp, double value, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) { return (await _db.ExecuteAsync(TimeSeriesCommandsBuilder.Add(key, timestamp, value, retentionTime, labels, uncompressed, chunkSizeBytes, duplicatePolicy))).ToTimeStamp(); @@ -192,6 +192,7 @@ public async Task> RevRangeAsync(string key, #region General /// + [Obsolete] public async Task InfoAsync(string key, bool debug = false) { return (await _db.ExecuteAsync(TimeSeriesCommandsBuilder.Info(key, debug))).ToTimeSeriesInfo(); From 9c56265dcbd1278f25ff1007dc39c0667c3c2e1d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 15:36:23 +0300 Subject: [PATCH 39/48] all warnings? --- .config/dotnet-tools.json | 12 ------------ src/NRedisStack/Graph/GraphCommands.cs | 1 + .../TimeSeries/TimeSeriesCommandsBuilder.cs | 4 ++-- 3 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json deleted file mode 100644 index ef84a272..00000000 --- a/.config/dotnet-tools.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "version": 1, - "isRoot": true, - "tools": { - "csharpier": { - "version": "0.25.0", - "commands": [ - "dotnet-csharpier" - ] - } - } -} \ No newline at end of file diff --git a/src/NRedisStack/Graph/GraphCommands.cs b/src/NRedisStack/Graph/GraphCommands.cs index 16894221..34740a2d 100644 --- a/src/NRedisStack/Graph/GraphCommands.cs +++ b/src/NRedisStack/Graph/GraphCommands.cs @@ -6,6 +6,7 @@ namespace NRedisStack { + [Obsolete] public class GraphCommands : GraphCommandsAsync, IGraphCommands { readonly IDatabase _db; diff --git a/src/NRedisStack/TimeSeries/TimeSeriesCommandsBuilder.cs b/src/NRedisStack/TimeSeries/TimeSeriesCommandsBuilder.cs index 9c3362e4..a9ae45a9 100644 --- a/src/NRedisStack/TimeSeries/TimeSeriesCommandsBuilder.cs +++ b/src/NRedisStack/TimeSeries/TimeSeriesCommandsBuilder.cs @@ -9,7 +9,7 @@ public static class TimeSeriesCommandsBuilder { #region Create - public static SerializedCommand Create(string key, long? retentionTime = null, IReadOnlyCollection labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) + public static SerializedCommand Create(string key, long? retentionTime = null, IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) { var args = TimeSeriesAux.BuildTsCreateArgs(key, retentionTime, labels, uncompressed, chunkSizeBytes, duplicatePolicy); return new SerializedCommand(TS.CREATE, args); @@ -26,7 +26,7 @@ public static SerializedCommand Alter(string key, long? retentionTime = null, lo } public static SerializedCommand Add(string key, TimeStamp timestamp, double value, long? retentionTime = null, - IReadOnlyCollection labels = null, bool? uncompressed = null, + IReadOnlyCollection? labels = null, bool? uncompressed = null, long? chunkSizeBytes = null, TsDuplicatePolicy? duplicatePolicy = null) { var args = TimeSeriesAux.BuildTsAddArgs(key, timestamp, value, retentionTime, labels, uncompressed, chunkSizeBytes, duplicatePolicy); From a488f2a62ca6ea1ce420ca5bdddd7bc23c8b61f2 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 16:30:43 +0300 Subject: [PATCH 40/48] more fixes --- src/NRedisStack/Graph/GraphCache.cs | 11 ++-- src/NRedisStack/Graph/GraphCacheList.cs | 9 +++- src/NRedisStack/Graph/GraphCommandsAsync.cs | 1 + src/NRedisStack/Graph/Header.cs | 12 +++-- src/NRedisStack/Graph/Record.cs | 4 +- src/NRedisStack/Graph/RedisGraphUtilities.cs | 2 +- src/NRedisStack/Graph/ResultSet.cs | 54 +++++++++---------- src/NRedisStack/Graph/Statistics.cs | 4 +- .../Json/DataTypes/KeyValuePath.cs | 2 +- src/NRedisStack/Json/JsonCommands.cs | 4 +- src/NRedisStack/ModulePrefixes.cs | 1 + src/NRedisStack/Pipeline.cs | 2 + src/NRedisStack/ResponseParser.cs | 32 +++++------ src/NRedisStack/Search/Document.cs | 4 +- src/NRedisStack/Search/Query.cs | 2 +- src/NRedisStack/Search/Reducer.cs | 4 +- src/NRedisStack/Search/Row.cs | 2 +- src/NRedisStack/Search/SearchCommands.cs | 4 +- src/NRedisStack/Search/SearchCommandsAsync.cs | 6 +-- src/NRedisStack/Search/SearchResult.cs | 2 +- .../TimeSeries/DataTypes/TimeSeriesTuple.cs | 2 +- .../TimeSeries/DataTypes/TimeStamp.cs | 2 +- .../TimeSeries/TimeSeriesCommands.cs | 2 +- src/NRedisStack/Transactions.cs | 2 + tests/NRedisStack.Tests/PipelineTests.cs | 4 +- 25 files changed, 96 insertions(+), 78 deletions(-) diff --git a/src/NRedisStack/Graph/GraphCache.cs b/src/NRedisStack/Graph/GraphCache.cs index fc9a2c39..327d019e 100644 --- a/src/NRedisStack/Graph/GraphCache.cs +++ b/src/NRedisStack/Graph/GraphCache.cs @@ -6,6 +6,7 @@ internal sealed class GraphCache public GraphCacheList PropertyNames { get; set; } public GraphCacheList RelationshipTypes { get; set; } + [Obsolete] public GraphCache(string graphName, GraphCommands redisGraph) { Labels = new GraphCacheList(graphName, "db.labels", redisGraph); @@ -13,6 +14,7 @@ public GraphCache(string graphName, GraphCommands redisGraph) RelationshipTypes = new GraphCacheList(graphName, "db.relationshipTypes", redisGraph); } + [Obsolete] public GraphCache(string graphName, GraphCommandsAsync redisGraph) { Labels = new GraphCacheList(graphName, "db.labels", redisGraph); @@ -20,11 +22,14 @@ public GraphCache(string graphName, GraphCommandsAsync redisGraph) RelationshipTypes = new GraphCacheList(graphName, "db.relationshipTypes", redisGraph); } - public string GetLabel(int index) => Labels.GetCachedData(index); + [Obsolete] + public string GetLabel(int index) => Labels.GetCachedData(index)!; - public string GetRelationshipType(int index) => RelationshipTypes.GetCachedData(index); + [Obsolete] + public string GetRelationshipType(int index) => RelationshipTypes.GetCachedData(index)!; - public string GetPropertyName(int index) => PropertyNames.GetCachedData(index); + [Obsolete] + public string GetPropertyName(int index) => PropertyNames.GetCachedData(index)!; } } \ No newline at end of file diff --git a/src/NRedisStack/Graph/GraphCacheList.cs b/src/NRedisStack/Graph/GraphCacheList.cs index 551e8476..acf62a51 100644 --- a/src/NRedisStack/Graph/GraphCacheList.cs +++ b/src/NRedisStack/Graph/GraphCacheList.cs @@ -6,7 +6,7 @@ internal sealed class GraphCacheList private readonly string _procedure; private string[] _data = Array.Empty(); - + [Obsolete] private readonly GraphCommandsAsync _redisGraph; private readonly object _locker = new object(); @@ -17,6 +17,7 @@ internal sealed class GraphCacheList /// The name of the graph to cache information for. /// The saved procedure to call to populate cache. Must be a `read` procedure. /// The graph used for the calling the . + [Obsolete] internal GraphCacheList(string graphName, string procedure, GraphCommands redisGraph) { _graphName = graphName; @@ -31,6 +32,7 @@ internal GraphCacheList(string graphName, string procedure, GraphCommands redisG /// The name of the graph to cache information for. /// The saved procedure to call to populate cache. Must be a `read` procedure. /// The graph used for the calling the . + [Obsolete] internal GraphCacheList(string graphName, string procedure, GraphCommandsAsync redisGraphAsync) { _graphName = graphName; @@ -40,7 +42,8 @@ internal GraphCacheList(string graphName, string procedure, GraphCommandsAsync r } // TODO: Change this to use Lazy? - internal string GetCachedData(int index) + [Obsolete] + internal string? GetCachedData(int index) { if (index >= _data.Length) { @@ -56,6 +59,7 @@ internal string GetCachedData(int index) return _data.ElementAtOrDefault(index); } + [Obsolete] private string[] GetProcedureInfo() { var resultSet = CallProcedure(); @@ -64,6 +68,7 @@ private string[] GetProcedureInfo() .ToArray(); } + [Obsolete] private ResultSet CallProcedure() { return _redisGraph is GraphCommands graphSync diff --git a/src/NRedisStack/Graph/GraphCommandsAsync.cs b/src/NRedisStack/Graph/GraphCommandsAsync.cs index 8f06f338..f095392e 100644 --- a/src/NRedisStack/Graph/GraphCommandsAsync.cs +++ b/src/NRedisStack/Graph/GraphCommandsAsync.cs @@ -7,6 +7,7 @@ namespace NRedisStack { + [Obsolete] public class GraphCommandsAsync : IGraphCommandsAsync { readonly IDatabaseAsync _db; diff --git a/src/NRedisStack/Graph/Header.cs b/src/NRedisStack/Graph/Header.cs index 26f0bf5c..9263a3bf 100644 --- a/src/NRedisStack/Graph/Header.cs +++ b/src/NRedisStack/Graph/Header.cs @@ -29,18 +29,20 @@ public enum ResultSetColumnTypes /// public List SchemaNames { get; } + [Obsolete] internal Header(RedisResult result) { SchemaTypes = new List(); SchemaNames = new List(); - foreach (RedisResult[] tuple in (RedisResult[])result) + foreach (RedisResult[]? tuple in (RedisResult[])result!) { - SchemaTypes.Add((ResultSetColumnTypes)(int)tuple[0]); - SchemaNames.Add((string)tuple[1]); + SchemaTypes.Add((ResultSetColumnTypes)(int)tuple![0]); + SchemaNames.Add((string)tuple[1]!); } } + [Obsolete] public override bool Equals(object? obj) { if (obj == null) return this == null; @@ -61,6 +63,7 @@ public override bool Equals(object? obj) && Object.Equals(SchemaNames, header.SchemaNames); } + [Obsolete] public override int GetHashCode() { unchecked @@ -72,8 +75,7 @@ public override int GetHashCode() } } - - + [Obsolete] public override string ToString() => $"Header{{schemaTypes=[{string.Join(", ", SchemaTypes)}], schemaNames=[{string.Join(", ", SchemaNames)}]}}"; } diff --git a/src/NRedisStack/Graph/Record.cs b/src/NRedisStack/Graph/Record.cs index be2346ec..e6bcebf7 100644 --- a/src/NRedisStack/Graph/Record.cs +++ b/src/NRedisStack/Graph/Record.cs @@ -37,14 +37,14 @@ internal Record(List header, List values) /// /// The index of the value that you want to get. /// The string value at the index that you specified. - public string GetString(int index) => Values[index].ToString(); + public string GetString(int index) => Values[index].ToString()!; /// /// Gets the string representation of a value by key. /// /// The key of the value that you want to get. /// The string value at the key that you specified. - public string GetString(string key) => Values[Header.IndexOf(key)].ToString(); + public string GetString(string key) => Values[Header.IndexOf(key)].ToString()!; /// /// Does the key exist in the record? diff --git a/src/NRedisStack/Graph/RedisGraphUtilities.cs b/src/NRedisStack/Graph/RedisGraphUtilities.cs index b8bac43e..9678d460 100644 --- a/src/NRedisStack/Graph/RedisGraphUtilities.cs +++ b/src/NRedisStack/Graph/RedisGraphUtilities.cs @@ -76,7 +76,7 @@ public static string ValueToString(object value) return ConvertibleToString(floatValue); } - return value.ToString(); + return value.ToString()!; } private static string ConvertibleToString(IConvertible floatValue) diff --git a/src/NRedisStack/Graph/ResultSet.cs b/src/NRedisStack/Graph/ResultSet.cs index 784c9b84..45291286 100644 --- a/src/NRedisStack/Graph/ResultSet.cs +++ b/src/NRedisStack/Graph/ResultSet.cs @@ -61,7 +61,7 @@ internal ResultSet(RedisResult result, GraphCache graphCache) { if (result.Type == ResultType.Error) { - throw new RedisServerException(result.ToString()); + throw new RedisServerException(result.ToString()!); } Statistics = ParseStatistics(result); @@ -131,16 +131,16 @@ private Node DeserializeNode(RedisResult[] rawNodeData) DeserializeGraphEntityId(node, rawNodeData[0]); - var labelIndices = (int[])rawNodeData[1]; + var labelIndices = (int[])rawNodeData[1]!; foreach (var labelIndex in labelIndices) { - var label = _graphCache.GetLabel(labelIndex); + var label = _graphCache!.GetLabel(labelIndex); node.Labels.Add(label); } - DeserializeGraphEntityProperties(node, (RedisResult[])rawNodeData[2]); + DeserializeGraphEntityProperties(node, (RedisResult[])rawNodeData[2]!); return node; } @@ -151,16 +151,16 @@ private Edge DeserializeEdge(RedisResult[] rawEdgeData) DeserializeGraphEntityId(edge, rawEdgeData[0]); - edge.RelationshipType = _graphCache.GetRelationshipType((int)rawEdgeData[1]); + edge.RelationshipType = _graphCache!.GetRelationshipType((int)rawEdgeData[1]); edge.Source = (int)rawEdgeData[2]; edge.Destination = (int)rawEdgeData[3]; - DeserializeGraphEntityProperties(edge, (RedisResult[])rawEdgeData[4]); + DeserializeGraphEntityProperties(edge, (RedisResult[])rawEdgeData[4]!); return edge; } - private object DeserializeScalar(RedisResult[] rawScalarData) + private object? DeserializeScalar(RedisResult[] rawScalarData) { var type = GetValueTypeFromObject(rawScalarData[0]); @@ -169,25 +169,25 @@ private object DeserializeScalar(RedisResult[] rawScalarData) case ResultSetScalarType.VALUE_NULL: return null; case ResultSetScalarType.VALUE_BOOLEAN: - return bool.Parse((string)rawScalarData[1]); + return bool.Parse((string)rawScalarData[1]!); case ResultSetScalarType.VALUE_DOUBLE: return (double)rawScalarData[1]; case ResultSetScalarType.VALUE_INT64: return (long)rawScalarData[1]; case ResultSetScalarType.VALUE_STRING: - return (string)rawScalarData[1]; + return (string)rawScalarData[1]!; case ResultSetScalarType.VALUE_ARRAY: - return DeserializeArray((RedisResult[])rawScalarData[1]); + return DeserializeArray((RedisResult[])rawScalarData[1]!); case ResultSetScalarType.VALUE_NODE: - return DeserializeNode((RedisResult[])rawScalarData[1]); + return DeserializeNode((RedisResult[])rawScalarData[1]!); case ResultSetScalarType.VALUE_EDGE: - return DeserializeEdge((RedisResult[])rawScalarData[1]); + return DeserializeEdge((RedisResult[])rawScalarData[1]!); case ResultSetScalarType.VALUE_PATH: - return DeserializePath((RedisResult[])rawScalarData[1]); + return DeserializePath((RedisResult[])rawScalarData[1]!); case ResultSetScalarType.VALUE_MAP: return DeserializeDictionary(rawScalarData[1]); case ResultSetScalarType.VALUE_POINT: - return DeserializePoint((RedisResult[])rawScalarData[1]); + return DeserializePoint((RedisResult[])rawScalarData[1]!); case ResultSetScalarType.VALUE_UNKNOWN: default: return (object)rawScalarData[1]; @@ -199,12 +199,12 @@ private static void DeserializeGraphEntityId(GraphEntity graphEntity, RedisResul private void DeserializeGraphEntityProperties(GraphEntity graphEntity, RedisResult[] rawProperties) { - foreach (RedisResult[] rawProperty in rawProperties) + foreach (RedisResult[]? rawProperty in rawProperties) { - var Key = _graphCache.GetPropertyName((int)rawProperty[0]); + var Key = _graphCache!.GetPropertyName((int)rawProperty![0]); var Value = DeserializeScalar(rawProperty.Skip(1).ToArray()); - graphEntity.PropertyMap.Add(Key, Value); + graphEntity.PropertyMap.Add(Key, Value!); } } @@ -215,7 +215,7 @@ private object[] DeserializeArray(RedisResult[] serializedArray) for (var i = 0; i < serializedArray.Length; i++) { - result[i] = DeserializeScalar((RedisResult[])serializedArray[i]); + result[i] = DeserializeScalar((RedisResult[])serializedArray[i]!)!; } return result; @@ -223,16 +223,16 @@ private object[] DeserializeArray(RedisResult[] serializedArray) private DataTypes.Path DeserializePath(RedisResult[] rawPath) { - var deserializedNodes = (object[])DeserializeScalar((RedisResult[])rawPath[0]); + var deserializedNodes = (object[])DeserializeScalar((RedisResult[])rawPath[0]!)!; var nodes = Array.ConvertAll(deserializedNodes, n => (Node)n); - var deserializedEdges = (object[])DeserializeScalar((RedisResult[])rawPath[1]); + var deserializedEdges = (object[])DeserializeScalar((RedisResult[])rawPath[1]!)!; var edges = Array.ConvertAll(deserializedEdges, p => (Edge)p); return new DataTypes.Path(nodes, edges); } - private object DeserializePoint(RedisResult[] rawPath) // Should return Point? + private object? DeserializePoint(RedisResult[] rawPath) // Should return Point? { if (null == rawPath) { @@ -250,15 +250,15 @@ private DataTypes.Path DeserializePath(RedisResult[] rawPath) // @SuppressWarnings("unchecked") private Dictionary DeserializeDictionary(RedisResult rawPath) { - RedisResult[] keyTypeValueEntries = (RedisResult[])rawPath; + RedisResult[] keyTypeValueEntries = (RedisResult[])rawPath!; int size = keyTypeValueEntries.Length; Dictionary dict = new Dictionary(size / 2); // set the capacity to half of the list for (int i = 0; i < size; i += 2) { - string key = keyTypeValueEntries[i].ToString(); - object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i + 1]); + string key = keyTypeValueEntries[i].ToString()!; + object value = DeserializeScalar((RedisResult[])keyTypeValueEntries[i + 1]!)!; dict.Add(key, value); } return dict; @@ -273,7 +273,7 @@ private static void ScanForErrors(RedisResult[] results) { if (result.Type == ResultType.Error) { - throw new RedisServerException(result.ToString()); + throw new RedisServerException(result.ToString()!); } } } @@ -284,7 +284,7 @@ private Statistics ParseStatistics(RedisResult result) if (result.Type == ResultType.MultiBulk) { - statistics = (RedisResult[])result; + statistics = (RedisResult[])result!; } else { @@ -294,7 +294,7 @@ private Statistics ParseStatistics(RedisResult result) return new Statistics( ((RedisResult[])statistics).Select(x => { - var s = ((string)x).Split(':'); + var s = ((string)x!).Split(':'); return new { diff --git a/src/NRedisStack/Graph/Statistics.cs b/src/NRedisStack/Graph/Statistics.cs index 66a5db99..a67f8c9c 100644 --- a/src/NRedisStack/Graph/Statistics.cs +++ b/src/NRedisStack/Graph/Statistics.cs @@ -20,8 +20,8 @@ internal Statistics(Dictionary statistics) RelationshipsDeleted = GetIntValue("Relationships deleted"); RelationshipsCreated = GetIntValue("Relationships created"); PropertiesSet = GetIntValue("Properties set"); - QueryInternalExecutionTime = GetStringValue("Query internal execution time"); - GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time"); + QueryInternalExecutionTime = GetStringValue("Query internal execution time")!; + GraphRemovedInternalExecutionTime = GetStringValue("Graph removed, internal execution time")!; CachedExecution = (GetIntValue("Cached execution") == 1); } diff --git a/src/NRedisStack/Json/DataTypes/KeyValuePath.cs b/src/NRedisStack/Json/DataTypes/KeyValuePath.cs index 252b639e..a5801e7e 100644 --- a/src/NRedisStack/Json/DataTypes/KeyValuePath.cs +++ b/src/NRedisStack/Json/DataTypes/KeyValuePath.cs @@ -18,7 +18,7 @@ public string[] ToArray() { if (Value is string) { - return new string[] { Key, Path, Value.ToString() }; + return new string[] { Key, Path, Value.ToString()! }; } return new string[] { Key, Path, JsonSerializer.Serialize(Value) }; } diff --git a/src/NRedisStack/Json/JsonCommands.cs b/src/NRedisStack/Json/JsonCommands.cs index d1e588f7..582036fa 100644 --- a/src/NRedisStack/Json/JsonCommands.cs +++ b/src/NRedisStack/Json/JsonCommands.cs @@ -241,7 +241,7 @@ public RedisResult Get(RedisKey key, string[] paths, RedisValue? indent = null, public IEnumerable GetEnumerable(RedisKey key, string path = "$") { RedisResult res = _db.Execute(JsonCommandBuilder.Get(key, path)); - return JsonSerializer.Deserialize>(res.ToString()); + return JsonSerializer.Deserialize>(res.ToString()!)!; } /// @@ -254,7 +254,7 @@ public RedisResult[] MGet(RedisKey[] keys, string path) public double?[] NumIncrby(RedisKey key, string path, double value) { var res = _db.Execute(JsonCommandBuilder.NumIncrby(key, path, value)); - return JsonSerializer.Deserialize(res.ToString()); + return JsonSerializer.Deserialize(res.ToString()!)!; } /// diff --git a/src/NRedisStack/ModulePrefixes.cs b/src/NRedisStack/ModulePrefixes.cs index e497f874..70dce707 100644 --- a/src/NRedisStack/ModulePrefixes.cs +++ b/src/NRedisStack/ModulePrefixes.cs @@ -10,6 +10,7 @@ public static class ModulePrefixes public static CmsCommands CMS(this IDatabase db) => new CmsCommands(db); + [Obsolete] public static GraphCommands GRAPH(this IDatabase db) => new GraphCommands(db); public static TopKCommands TOPK(this IDatabase db) => new TopKCommands(db); diff --git a/src/NRedisStack/Pipeline.cs b/src/NRedisStack/Pipeline.cs index 182a73c2..67f23ff8 100644 --- a/src/NRedisStack/Pipeline.cs +++ b/src/NRedisStack/Pipeline.cs @@ -17,6 +17,8 @@ public Pipeline(IDatabase db) public BloomCommandsAsync Bf => new BloomCommandsAsync(_batch); public CmsCommandsAsync Cms => new CmsCommandsAsync(_batch); public CuckooCommandsAsync Cf => new CuckooCommandsAsync(_batch); + + [Obsolete] public GraphCommandsAsync Graph => new GraphCommandsAsync(_batch); public JsonCommandsAsync Json => new JsonCommandsAsync(_batch); public SearchCommandsAsync Ft => new SearchCommandsAsync(_batch); diff --git a/src/NRedisStack/ResponseParser.cs b/src/NRedisStack/ResponseParser.cs index 4097b1f6..81f22eb3 100644 --- a/src/NRedisStack/ResponseParser.cs +++ b/src/NRedisStack/ResponseParser.cs @@ -80,7 +80,7 @@ public static long[] ToLongArray(this RedisResult result) public static TimeStamp ToTimeStamp(this RedisResult result) { - if (result.Type == ResultType.None) return null; + if (result.Type == ResultType.None) return null!; return new TimeStamp((long)result); } @@ -93,17 +93,17 @@ public static IReadOnlyList ToTimeStampArray(this RedisResult result) return list; } - public static TimeSeriesTuple? ToTimeSeriesTuple(this RedisResult result) + public static TimeSeriesTuple ToTimeSeriesTuple(this RedisResult result) { RedisResult[] redisResults = result.ToArray(); - if (redisResults.Length == 0) return null; + if (redisResults.Length == 0) return null!; return new TimeSeriesTuple(ToTimeStamp(redisResults[0]), (double)redisResults[1]); } - public static Tuple? ToScanDumpTuple(this RedisResult result) + public static Tuple ToScanDumpTuple(this RedisResult result) { RedisResult[] redisResults = result.ToArray(); - if (redisResults == null || redisResults.Length == 0) return null; + if (redisResults == null || redisResults.Length == 0) return null!; return new Tuple((long)redisResults[0], (byte[])redisResults[1]!); } @@ -146,7 +146,7 @@ public static IReadOnlyList ToLabelArray(this RedisResult resul Array.ForEach(redisResults, labelResult => { var labelTuple = (RedisResult[])labelResult!; - list.Add(new TimeSeriesLabel(labelTuple[0].ToString(), labelTuple[1].ToString())); + list.Add(new TimeSeriesLabel(labelTuple[0].ToString()!, labelTuple[1].ToString()!)); }); return list; } @@ -172,7 +172,7 @@ public static IReadOnlyList ToLabelArray(this RedisResult resul Array.ForEach(redisResults, MRangeValue => { var MRangeTuple = (RedisResult[])MRangeValue!; - string key = MRangeTuple[0].ToString(); + string key = MRangeTuple[0].ToString()!; IReadOnlyList labels = ToLabelArray(MRangeTuple[1]); TimeSeriesTuple? value = ToTimeSeriesTuple(MRangeTuple[2]); list.Add((key!, labels!, value!)); @@ -188,7 +188,7 @@ public static IReadOnlyList ToLabelArray(this RedisResult resul Array.ForEach(redisResults, MRangeValue => { var MRangeTuple = (RedisResult[])MRangeValue!; - string key = MRangeTuple[0].ToString(); + string key = MRangeTuple[0].ToString()!; IReadOnlyList labels = ToLabelArray(MRangeTuple[1]); IReadOnlyList values = ToTimeSeriesTupleArray(MRangeTuple[2]); list.Add((key, labels, values)); @@ -199,9 +199,9 @@ public static IReadOnlyList ToLabelArray(this RedisResult resul public static TimeSeriesRule ToRule(this RedisResult result) { var redisResults = (RedisResult[])result!; - string destKey = redisResults[0].ToString(); + string destKey = redisResults[0].ToString()!; long bucketTime = (long)redisResults[1]; - var aggregation = AggregationExtensions.AsAggregation(redisResults[2].ToString()); + var aggregation = AggregationExtensions.AsAggregation(redisResults[2].ToString()!); return new TimeSeriesRule(destKey, bucketTime, aggregation); } @@ -432,7 +432,7 @@ public static TimeSeriesInformation ToTimeSeriesInfo(this RedisResult result) var redisResults = (RedisResult[])result!; for (int i = 0; i < redisResults.Length; ++i) { - string label = redisResults[i++].ToString(); + string label = redisResults[i++].ToString()!; switch (label) { case "totalSamples": @@ -512,7 +512,7 @@ public static Dictionary ToConfigDictionary(this RedisResult val foreach (var pair in res) { var arr = (RedisResult[])pair!; - dict.Add(arr[0].ToString(), arr[1].ToString()); + dict.Add(arr[0].ToString()!, arr[1].ToString()!); } return dict; } @@ -533,7 +533,7 @@ public static TimeSeriesChunck ToTimeSeriesChunk(this RedisResult result) var redisResults = (RedisResult[])result!; for (int i = 0; i < redisResults.Length; ++i) { - string label = redisResults[i++].ToString(); + string label = redisResults[i++].ToString()!; switch (label) { case "startTimestamp": @@ -549,7 +549,7 @@ public static TimeSeriesChunck ToTimeSeriesChunk(this RedisResult result) size = (long)redisResults[i]; break; case "bytesPerSample": - bytesPerSample = redisResults[i].ToString(); + bytesPerSample = redisResults[i].ToString()!; break; } } @@ -565,7 +565,7 @@ public static List ToStringList(this RedisResult result) var list = new List(); if (redisResults.Length == 0) return list; - Array.ForEach(redisResults, str => list.Add(str.ToString())); + Array.ForEach(redisResults, str => list.Add(str.ToString()!)); return list; } @@ -662,7 +662,7 @@ public static Dictionary ToStringRedisResultDictionary(this foreach (var pair in res) { var arr = (RedisResult[])pair!; - dict.Add(arr[0].ToString(), arr[1]); + dict.Add(arr[0].ToString()!, arr[1]); } return dict; } diff --git a/src/NRedisStack/Search/Document.cs b/src/NRedisStack/Search/Document.cs index 1b26b029..159071d4 100644 --- a/src/NRedisStack/Search/Document.cs +++ b/src/NRedisStack/Search/Document.cs @@ -12,7 +12,7 @@ public class Document public byte[]? Payload { get; } public string[]? ScoreExplained { get; private set; } // TODO: check if this is needed (Jedis does not have it) internal readonly Dictionary _properties; - public Document(string id, double score, byte[] payload) : this(id, null, score, payload) { } + public Document(string id, double score, byte[]? payload) : this(id, null, score, payload) { } public Document(string id) : this(id, null, 1.0, null) { } public Document(string id, Dictionary fields, double score = 1.0) : this(id, fields, score, null) { } @@ -27,7 +27,7 @@ public Document(string id, Dictionary? fields, double score, public IEnumerable> GetProperties() => _properties; - public static Document Load(string id, double score, byte[] payload, RedisValue[] fields) + public static Document Load(string id, double score, byte[]? payload, RedisValue[]? fields) { Document ret = new Document(id, score, payload); if (fields != null) diff --git a/src/NRedisStack/Search/Query.cs b/src/NRedisStack/Search/Query.cs index 5eafb572..baa41598 100644 --- a/src/NRedisStack/Search/Query.cs +++ b/src/NRedisStack/Search/Query.cs @@ -585,7 +585,7 @@ private Query HighlightFieldsImpl(HighlightTags? tags, string[] fields) return this; } - public Query SummarizeFields(int contextLen, int fragmentCount, string separator, params string[] fields) + public Query SummarizeFields(int contextLen, int fragmentCount, string? separator, params string[] fields) { if (fields == null || fields.Length > 0) { diff --git a/src/NRedisStack/Search/Reducer.cs b/src/NRedisStack/Search/Reducer.cs index 0a870024..a55fcd5a 100644 --- a/src/NRedisStack/Search/Reducer.cs +++ b/src/NRedisStack/Search/Reducer.cs @@ -10,10 +10,10 @@ public abstract class Reducer public abstract string Name { get; } public string? Alias { get; set; } - private readonly string _field; + private readonly string? _field; - protected Reducer(string field) + protected Reducer(string? field) { _field = field; Alias = null; diff --git a/src/NRedisStack/Search/Row.cs b/src/NRedisStack/Search/Row.cs index 12795ffc..0caac94e 100644 --- a/src/NRedisStack/Search/Row.cs +++ b/src/NRedisStack/Search/Row.cs @@ -14,7 +14,7 @@ internal Row(Dictionary fields) public bool ContainsKey(string key) => _fields.ContainsKey(key); public RedisValue this[string key] => _fields.TryGetValue(key, out var result) ? result : RedisValue.Null; - public string GetString(string key) => _fields.TryGetValue(key, out var result) ? (string)result : default; + public string? GetString(string key) => _fields.TryGetValue(key, out var result) ? result.ToString() : default; public long GetLong(string key) => _fields.TryGetValue(key, out var result) ? (long)result : default; public double GetDouble(string key) => _fields.TryGetValue(key, out var result) ? (double)result : default; } diff --git a/src/NRedisStack/Search/SearchCommands.cs b/src/NRedisStack/Search/SearchCommands.cs index 30a1e58d..9bb74dde 100644 --- a/src/NRedisStack/Search/SearchCommands.cs +++ b/src/NRedisStack/Search/SearchCommands.cs @@ -134,7 +134,7 @@ public string Explain(string indexName, string query, int? dialect = null) { dialect = defaultDialect; } - return _db.Execute(SearchCommandBuilder.Explain(indexName, query, dialect)).ToString(); + return _db.Execute(SearchCommandBuilder.Explain(indexName, query, dialect)).ToString()!; } /// @@ -222,7 +222,7 @@ public Dictionary> SynDump(string indexName) { var term = resp[i].ToString(); var synonyms = (resp[i + 1]).ToArray().Select(x => x.ToString()).ToList(); // TODO: consider leave synonyms as RedisValue[] - result.Add(term, synonyms); + result.Add(term!, synonyms!); } return result; } diff --git a/src/NRedisStack/Search/SearchCommandsAsync.cs b/src/NRedisStack/Search/SearchCommandsAsync.cs index 96994a73..6935e948 100644 --- a/src/NRedisStack/Search/SearchCommandsAsync.cs +++ b/src/NRedisStack/Search/SearchCommandsAsync.cs @@ -31,7 +31,7 @@ public async Task AggregateAsync(string index, AggregationReq var result = await _db.ExecuteAsync(SearchCommandBuilder.Aggregate(index, query)); if (query.IsWithCursor()) { - var results = (RedisResult[])result; + var results = (RedisResult[])result!; return new AggregationResult(results[0], (long)results[1]); } @@ -134,7 +134,7 @@ public async Task ExplainAsync(string indexName, string query, int? dial dialect = defaultDialect; } - return (await _db.ExecuteAsync(SearchCommandBuilder.Explain(indexName, query, dialect))).ToString(); + return (await _db.ExecuteAsync(SearchCommandBuilder.Explain(indexName, query, dialect))).ToString()!; } /// @@ -227,7 +227,7 @@ public async Task>> SynDumpAsync(string indexNam { var term = resp[i].ToString(); var synonyms = (resp[i + 1]).ToArray().Select(x => x.ToString()).ToList(); // TODO: consider leave synonyms as RedisValue[] - result.Add(term, synonyms); + result.Add(term!, synonyms!); } return result; } diff --git a/src/NRedisStack/Search/SearchResult.cs b/src/NRedisStack/Search/SearchResult.cs index 1d75ffd1..51c34e95 100644 --- a/src/NRedisStack/Search/SearchResult.cs +++ b/src/NRedisStack/Search/SearchResult.cs @@ -79,7 +79,7 @@ internal SearchResult(RedisResult[] resp, bool hasContent, bool hasScores, bool fields = (RedisValue[]?)resp[i + contentOffset]; } - docs.Add(Document.Load(id, score, payload, fields, scoreExplained)); + docs.Add(Document.Load(id!, score, payload, fields, scoreExplained)); } } } diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs index abba2ec5..c1f24e32 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs @@ -37,7 +37,7 @@ obj is TimeSeriesTuple tuple && /// /// TimeSeriesTuple public static implicit operator string(TimeSeriesTuple tst) => - string.Format("Time: {0}, Val:{1}", (string)tst.Time, tst.Val); + string.Format("Time: {0}, Val:{1}", tst.Time.ToString(), tst.Val); /// /// TimeSeriesTuple object hash code. diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs index cf523060..86892ac3 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeStamp.cs @@ -64,7 +64,7 @@ public static implicit operator long(TimeStamp ts) => /// Implicit cast from TimeStamp to string. /// /// TimeStamp - public static implicit operator string? (TimeStamp ts) => ts.Value.ToString(); + public static implicit operator string?(TimeStamp ts) => ts.Value.ToString(); /// /// Implicit cast from DateTime to TimeStamp. diff --git a/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs b/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs index efbeb31f..3b304b79 100644 --- a/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs +++ b/src/NRedisStack/TimeSeries/TimeSeriesCommands.cs @@ -44,7 +44,7 @@ public TimeStamp Add(string key, TimeStamp timestamp, double value, long? retent /// public IReadOnlyList MAdd(IReadOnlyCollection<(string key, TimeStamp timestamp, double value)> sequence) { - return _db.Execute(TimeSeriesCommandsBuilder.MAdd(sequence)).ToTimeStampArray(); + return _db.Execute(TimeSeriesCommandsBuilder.MAdd(sequence)).ToTimeStampArray()!; } /// diff --git a/src/NRedisStack/Transactions.cs b/src/NRedisStack/Transactions.cs index f260fe6d..b14e68de 100644 --- a/src/NRedisStack/Transactions.cs +++ b/src/NRedisStack/Transactions.cs @@ -21,6 +21,8 @@ public Transaction(IDatabase db) public BloomCommandsAsync Bf => new BloomCommandsAsync(_transaction); public CmsCommandsAsync Cms => new CmsCommandsAsync(_transaction); public CuckooCommandsAsync Cf => new CuckooCommandsAsync(_transaction); + + [Obsolete] public GraphCommandsAsync Graph => new GraphCommandsAsync(_transaction); public JsonCommandsAsync Json => new JsonCommandsAsync(_transaction); public SearchCommandsAsync Ft => new SearchCommandsAsync(_transaction); diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 4142ebab..8afaa2d6 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -51,7 +51,7 @@ public async Task TestModulsPipeline() Assert.True(db.KeyExists("cf-key")); Assert.True(db.KeyExists("graph-key")); Assert.True(db.KeyExists("json-key")); - Assert.Equal(1, db.FT()._List().Length); + Assert.Single(db.FT()._List()); Assert.True(db.KeyExists("tdigest-key")); Assert.True(db.KeyExists("ts-key")); Assert.True(db.KeyExists("topk-key")); @@ -99,7 +99,7 @@ public async Task TestModulsPipelineWithotGraph() Assert.True(db.KeyExists("cms-key")); Assert.True(db.KeyExists("cf-key")); Assert.True(db.KeyExists("json-key")); - Assert.Equal(1, db.FT()._List().Length); + Assert.Single(db.FT()._List()); Assert.True(db.KeyExists("tdigest-key")); Assert.True(db.KeyExists("ts-key")); Assert.True(db.KeyExists("topk-key")); From 34e7b35924317c5cc689ca97d0e93699d0c79f8e Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 16:45:03 +0300 Subject: [PATCH 41/48] string format error --- src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs index c1f24e32..bc4afd85 100644 --- a/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs +++ b/src/NRedisStack/TimeSeries/DataTypes/TimeSeriesTuple.cs @@ -37,7 +37,7 @@ obj is TimeSeriesTuple tuple && /// /// TimeSeriesTuple public static implicit operator string(TimeSeriesTuple tst) => - string.Format("Time: {0}, Val:{1}", tst.Time.ToString(), tst.Val); + string.Format("Time: {0}, Val:{1}", (string)tst.Time!, tst.Val); /// /// TimeSeriesTuple object hash code. From c01f7eef40f712da28ff8232e6193ba3c89eb19c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 16:48:01 +0300 Subject: [PATCH 42/48] warnings --- src/NRedisStack/Graph/DataTypes/Edge.cs | 2 +- .../Search/DataTypes/InfoResult.cs | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/NRedisStack/Graph/DataTypes/Edge.cs b/src/NRedisStack/Graph/DataTypes/Edge.cs index 24e7df5b..30308787 100644 --- a/src/NRedisStack/Graph/DataTypes/Edge.cs +++ b/src/NRedisStack/Graph/DataTypes/Edge.cs @@ -12,7 +12,7 @@ public class Edge : GraphEntity /// The relationship type. /// /// - public string RelationshipType { get; set; } + public string? RelationshipType { get; set; } /// /// The ID of the source node. diff --git a/src/NRedisStack/Search/DataTypes/InfoResult.cs b/src/NRedisStack/Search/DataTypes/InfoResult.cs index e0d21de6..f245b5d8 100644 --- a/src/NRedisStack/Search/DataTypes/InfoResult.cs +++ b/src/NRedisStack/Search/DataTypes/InfoResult.cs @@ -6,15 +6,15 @@ public class InfoResult { private readonly Dictionary _all = new Dictionary(); - public string IndexName => GetString("index_name"); - public Dictionary IndexOption => GetRedisResultDictionary("index_options"); + public string IndexName => GetString("index_name")!; + public Dictionary IndexOption => GetRedisResultDictionary("index_options")!; - public Dictionary[] Attributes => GetRedisResultDictionaryArray("attributes"); + public Dictionary[] Attributes => GetRedisResultDictionaryArray("attributes")!; public long NumDocs => GetLong("num_docs"); - public string MaxDocId => GetString("max_doc_id"); + public string MaxDocId => GetString("max_doc_id")!; public long NumTerms => GetLong("num_terms"); @@ -59,24 +59,24 @@ public class InfoResult public long NumberOfUses => GetLong("number_of_uses"); - public Dictionary GcStats => GetRedisResultDictionary("gc_stats"); + public Dictionary GcStats => GetRedisResultDictionary("gc_stats")!; - public Dictionary CursorStats => GetRedisResultDictionary("cursor_stats"); + public Dictionary CursorStats => GetRedisResultDictionary("cursor_stats")!; public InfoResult(RedisResult result) { - var results = (RedisResult[])result; + var results = (RedisResult[])result!; for (var i = 0; i < results.Length; i += 2) { - var key = (string)results[i]; + var key = (string)results[i]!; var value = results[i + 1]; _all.Add(key, value); } } - private string GetString(string key) => _all.TryGetValue(key, out var value) ? (string)value : default; + private string? GetString(string key) => _all.TryGetValue(key, out var value) ? (string)value! : default; private long GetLong(string key) => _all.TryGetValue(key, out var value) ? (long)value : default; @@ -84,7 +84,7 @@ private double GetDouble(string key) { if (_all.TryGetValue(key, out var value)) { - if ((string)value == "-nan") + if ((string)value! == "-nan") { return default; } @@ -99,16 +99,16 @@ private double GetDouble(string key) } } - private Dictionary GetRedisResultDictionary(string key) + private Dictionary? GetRedisResultDictionary(string key) { if (_all.TryGetValue(key, out var value)) { - var values = (RedisResult[])value; + var values = (RedisResult[])value!; var result = new Dictionary(); for (var ii = 0; ii < values.Length; ii += 2) { - result.Add((string)values[ii], values[ii + 1]); + result.Add((string)values[ii]!, values[ii + 1]); } return result; @@ -119,19 +119,19 @@ private Dictionary GetRedisResultDictionary(string key) } } - private Dictionary[] GetRedisResultDictionaryArray(string key) + private Dictionary[]? GetRedisResultDictionaryArray(string key) { if (_all.TryGetValue(key, out var value)) { - var values = (RedisResult[])value; + var values = (RedisResult[])value!; var result = new Dictionary[values.Length]; for (int i = 0; i < values.Length; i++) { - var fv = (RedisResult[])values[i]; + var fv = (RedisResult[])values[i]!; var dict = new Dictionary(); for (int j = 0; j < fv.Length; j += 2) { - dict.Add((string)fv[j], fv[j + 1]); + dict.Add((string)fv[j]!, fv[j + 1]); } result[i] = dict; } From 3b90ba0bc00de5dab77cf466a2ce45a643924e8c Mon Sep 17 00:00:00 2001 From: shacharPash Date: Mon, 11 Sep 2023 16:58:28 +0300 Subject: [PATCH 43/48] more --- src/NRedisStack/Graph/DataTypes/Edge.cs | 2 +- src/NRedisStack/Search/AggregationResult.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NRedisStack/Graph/DataTypes/Edge.cs b/src/NRedisStack/Graph/DataTypes/Edge.cs index 30308787..cf005f5c 100644 --- a/src/NRedisStack/Graph/DataTypes/Edge.cs +++ b/src/NRedisStack/Graph/DataTypes/Edge.cs @@ -66,7 +66,7 @@ public override int GetHashCode() int hash = 17; hash = hash * 31 + base.GetHashCode(); - hash = hash * 31 + RelationshipType.GetHashCode(); + hash = hash * 31 + RelationshipType!.GetHashCode(); hash = hash * 31 + Source.GetHashCode(); hash = hash * 31 + Destination.GetHashCode(); diff --git a/src/NRedisStack/Search/AggregationResult.cs b/src/NRedisStack/Search/AggregationResult.cs index 70c2dffb..b8e4d38e 100644 --- a/src/NRedisStack/Search/AggregationResult.cs +++ b/src/NRedisStack/Search/AggregationResult.cs @@ -11,7 +11,7 @@ public sealed class AggregationResult internal AggregationResult(RedisResult result, long cursorId = -1) { - var arr = (RedisResult[])result; + var arr = (RedisResult[])result!; // the first element is always the number of results TotalResults = (long)arr[0]; @@ -19,11 +19,11 @@ internal AggregationResult(RedisResult result, long cursorId = -1) _results = new Dictionary[arr.Length - 1]; for (int i = 1; i < arr.Length; i++) { - var raw = (RedisResult[])arr[i]; + var raw = (RedisResult[])arr[i]!; var cur = new Dictionary(); for (int j = 0; j < raw.Length;) { - var key = (string)raw[j++]; + var key = (string)raw[j++]!; var val = raw[j++]; if (val.Type == ResultType.MultiBulk) continue; // TODO: handle multi-bulk (maybe change to object?) @@ -36,7 +36,7 @@ internal AggregationResult(RedisResult result, long cursorId = -1) } public IReadOnlyList> GetResults() => _results; - public Dictionary this[int index] + public Dictionary? this[int index] => index >= _results.Length ? null : _results[index]; public Row GetRow(int index) From ed332048d0b60918b6b417b4f99a716a7029c9cd Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 26 Sep 2023 16:59:28 +0300 Subject: [PATCH 44/48] format --- tests/NRedisStack.Tests/Search/SearchTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index d54a8d56..c088b26f 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -1160,7 +1160,7 @@ public void TestDictionary() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, ft.DictDel("dict", "foo", "bar", "hello world")); - Assert.Equal(0, ft.DictDump("dict").Length); + Assert.Empty(ft.DictDump("dict")); } [SkipIfRedis(Is.OSSCluster)] @@ -1297,7 +1297,7 @@ public async Task TestDictionaryAsync() Assert.Equal("hello world", dumResult[i].ToString()); Assert.Equal(3L, await ft.DictDelAsync("dict", "foo", "bar", "hello world")); - Assert.Equal(0, (await ft.DictDumpAsync("dict")).Length); + Assert.Empty((await ft.DictDumpAsync("dict"))); } string explainQuery = "@f3:f3_val @f2:f2_val @f1:f1_val"; From a353196a1e4eb0152b29eb650f6b5147738d19ac Mon Sep 17 00:00:00 2001 From: shacharPash Date: Tue, 26 Sep 2023 17:58:15 +0300 Subject: [PATCH 45/48] clean all warnings? --- .../Examples/ExampleTests.cs | 24 +-- tests/NRedisStack.Tests/Graph/GraphTests.cs | 184 +++++++++++------- tests/NRedisStack.Tests/Json/JsonTests.cs | 13 +- tests/NRedisStack.Tests/PipelineTests.cs | 16 +- tests/NRedisStack.Tests/Search/SearchTests.cs | 26 +-- .../TimeSeries/TestAPI/TestAdd.cs | 9 +- .../TimeSeries/TestAPI/TestAlter.cs | 3 + .../TimeSeries/TestAPI/TestCreate.cs | 4 + .../TimeSeries/TestAPI/TestDecrBy.cs | 12 +- .../TimeSeries/TestAPI/TestGet.cs | 2 +- .../TimeSeries/TestAPI/TestIncrBy.cs | 12 +- .../TimeSeries/TestAPI/TestMADD.cs | 3 +- .../TimeSeries/TestAPI/TestMAddAsync.cs | 3 +- .../TimeSeries/TestAPI/TestRules.cs | 1 + .../TimeSeries/TestAPI/TestRulesAsync.cs | 1 + tests/NRedisStack.Tests/TopK/TopKTests.cs | 2 +- tests/NRedisStack.Tests/TransactionsTests.cs | 23 +-- 17 files changed, 199 insertions(+), 139 deletions(-) diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index de9a6971..f788f4af 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -105,13 +105,13 @@ public void PipelineExample() pipeline.Json.SetAsync("person", "$", new { name = "John", age = 30, city = "New York", nicknames = new[] { "John", "Johny", "Jo" } }); // Increase age by 2 - pipeline.Json.NumIncrbyAsync("person", "$.age", 2); + _ = pipeline.Json.NumIncrbyAsync("person", "$.age", 2); // Clear the nicknames from the Json - pipeline.Json.ClearAsync("person", "$.nicknames"); + _ = pipeline.Json.ClearAsync("person", "$.nicknames"); // Del the nicknames - pipeline.Json.DelAsync("person", "$.nicknames"); + _ = pipeline.Json.DelAsync("person", "$.nicknames"); // Get the Json response var getResponse = pipeline.Json.GetAsync("person"); @@ -192,8 +192,8 @@ public async Task PipelineWithAsync() var labels2 = new List { label2 }; // Create a new time-series. - pipeline.Ts.CreateAsync("temp:TLV", labels: labels1); - pipeline.Ts.CreateAsync("temp:JLM", labels: labels2); + _ = pipeline.Ts.CreateAsync("temp:TLV", labels: labels1); + _ = pipeline.Ts.CreateAsync("temp:JLM", labels: labels2); // Adding multiple sequenece of time-series data. List<(string, TimeStamp, double)> sequence1 = new List<(string, TimeStamp, double)>() @@ -212,8 +212,8 @@ public async Task PipelineWithAsync() }; // Adding mutiple samples to mutiple series. - pipeline.Ts.MAddAsync(sequence1); - pipeline.Ts.MAddAsync(sequence2); + _ = pipeline.Ts.MAddAsync(sequence1); + _ = pipeline.Ts.MAddAsync(sequence2); // Execute the pipeline pipeline.Execute(); @@ -230,7 +230,7 @@ public async Task PipelineWithAsync() } [SkipIfRedis(Is.OSSCluster)] - public async Task TransactionExample() + public void TransactionExample() { // Connect to the Redis server // var redis = ConnectionMultiplexer.Connect("localhost"); @@ -245,18 +245,18 @@ public async Task TransactionExample() var tran = new Transaction(db); // Add account details with Json.Set to transaction - tran.Json.SetAsync("accdetails:Jeeva", "$", new { name = "Jeeva", totalAmount = 1000, bankName = "City" }); - tran.Json.SetAsync("accdetails:Shachar", "$", new { name = "Shachar", totalAmount = 1000, bankName = "City" }); + _ = tran.Json.SetAsync("accdetails:Jeeva", "$", new { name = "Jeeva", totalAmount = 1000, bankName = "City" }); + _ = tran.Json.SetAsync("accdetails:Shachar", "$", new { name = "Shachar", totalAmount = 1000, bankName = "City" }); // Get the Json response var getShachar = tran.Json.GetAsync("accdetails:Shachar"); var getJeeva = tran.Json.GetAsync("accdetails:Jeeva"); // Debit 200 from Jeeva - tran.Json.NumIncrbyAsync("accdetails:Jeeva", "$.totalAmount", -200); + _ = tran.Json.NumIncrbyAsync("accdetails:Jeeva", "$.totalAmount", -200); // Credit 200 from Shachar - tran.Json.NumIncrbyAsync("accdetails:Shachar", "$.totalAmount", 200); + _ = tran.Json.NumIncrbyAsync("accdetails:Shachar", "$.totalAmount", 200); // Get total amount for both Jeeva = 800 & Shachar = 1200 var totalAmtOfJeeva = tran.Json.GetAsync("accdetails:Jeeva", path: "$.totalAmount"); diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 4c5f397a..b9dae8f7 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -14,14 +14,7 @@ public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } #region SyncTests [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] - public void TestReserveBasic() - { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); - var graph = db.GRAPH(); - } - - [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestCreateNode() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -45,6 +38,7 @@ public void TestCreateNode() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestCreateLabeledNode() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -66,6 +60,7 @@ public void TestCreateLabeledNode() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestConnectNodes() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -93,6 +88,7 @@ public void TestConnectNodes() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestDeleteNodes() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -140,6 +136,7 @@ public void TestDeleteNodes() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestDeleteRelationship() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -170,6 +167,7 @@ public void TestDeleteRelationship() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestIndex() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -197,6 +195,7 @@ public void TestIndex() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestHeader() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -210,7 +209,7 @@ public void TestHeader() ResultSet queryResult = graph.Query("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r, a.age"); - Header header = queryResult.Header; + Header header = queryResult.Header!; Assert.NotNull(header); Assert.Equal("Header{" // + "schemaTypes=[COLUMN_SCALAR, COLUMN_SCALAR, COLUMN_SCALAR], " @@ -228,6 +227,7 @@ public void TestHeader() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestRecord() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -353,6 +353,7 @@ public void TestRecord() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestAdditionToProcedures() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -383,7 +384,7 @@ public void TestAdditionToProcedures() ResultSet resultSet = graph.Query("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r"); Assert.NotNull(resultSet.Header); - Header header = resultSet.Header; + Header header = resultSet.Header!; List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); Assert.Equal(2, schemaNames.Count); @@ -416,7 +417,7 @@ public void TestAdditionToProcedures() "MATCH (a:worker), (b:worker) WHERE (a.lastName = 'a' AND b.lastName='b') CREATE (a)-[:worksWith]->(b)")); resultSet = graph.Query("social", "MATCH (a:worker)-[r:worksWith]->(b:worker) RETURN a,r"); Assert.NotNull(resultSet.Header); - header = resultSet.Header; + header = resultSet.Header!; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); Assert.Equal(2, schemaNames.Count); @@ -433,6 +434,7 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestEscapedQuery() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -452,6 +454,7 @@ public void TestEscapedQuery() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestArraySupport() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -487,7 +490,7 @@ public void TestArraySupport() // check header Assert.NotNull(resultSet.Header); - Header header = resultSet.Header; + Header header = resultSet.Header!; List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); @@ -509,7 +512,7 @@ public void TestArraySupport() resultSet = graph.Query("social", "MATCH(n) return collect(n) as x"); Assert.NotNull(resultSet.Header); - header = resultSet.Header; + header = resultSet.Header!; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); @@ -532,7 +535,7 @@ record = iterator.Current; resultSet = graph.Query("social", "unwind([0,1,2]) as x return x"); Assert.NotNull(resultSet.Header); - header = resultSet.Header; + header = resultSet.Header!; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); @@ -552,6 +555,7 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestPath() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -604,6 +608,7 @@ public void TestPath() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestNullGraphEntities() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -618,7 +623,9 @@ public void TestNullGraphEntities() Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; Assert.False(iterator.MoveNext()); - Assert.Equal(new List() { null, null, null }, record.Values); + Assert.Equal(new List() { null!, null!, null! }, record.Values); + + // Test a query that produces 2 records, with 2 null values in the second. resultSet = graph.Query("social", "MATCH (a) OPTIONAL MATCH (a)-[e]->(b) RETURN a, e, b ORDER BY ID(a)"); @@ -658,6 +665,7 @@ record = resultSet.Skip(1).First(); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void Test64BitNumber() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -676,6 +684,7 @@ public void Test64BitNumber() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestCachedExecution() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -707,24 +716,26 @@ public void TestCachedExecution() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestMapDataType() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var graph = db.GRAPH(); - Dictionary expected = new Dictionary(); - expected.Add("a", (long)1); - expected.Add("b", "str"); - expected.Add("c", null); - List d = new List(); - d.Add((long)1); - d.Add((long)2); - d.Add((long)3); + Dictionary expected = new Dictionary + { + { "a", (long)1 }, + { "b", "str" }, + { "c", null } + }; + List d = new List { 1L, 2L, 3L }; expected.Add("d", d); expected.Add("e", true); - Dictionary f = new Dictionary(); - f.Add("x", (long)1); - f.Add("y", (long)2); + Dictionary f = new Dictionary + { + { "x", (long)1 }, + { "y", (long)2 } + }; expected.Add("f", f); ResultSet res = graph.Query("social", "RETURN {a:1, b:'str', c:NULL, d:[1,2,3], e:True, f:{x:1, y:2}}"); Assert.Single(res); @@ -737,6 +748,7 @@ public void TestMapDataType() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestGeoPointLatLon() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -751,6 +763,7 @@ public void TestGeoPointLatLon() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestGeoPointLonLat() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -764,6 +777,7 @@ public void TestGeoPointLonLat() AssertTestGeoPoint(graph); } + [Obsolete] private void AssertTestGeoPoint(IGraphCommands graph) { ResultSet results = graph.Query("social", "MATCH (restaurant) RETURN restaurant"); @@ -780,6 +794,7 @@ private void AssertTestGeoPoint(IGraphCommands graph) } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestPoint() { var point = new Point(30.27822306, -97.75134723); @@ -792,6 +807,7 @@ public void TestPoint() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void timeoutArgument() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -802,10 +818,11 @@ public void timeoutArgument() var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; - Assert.Equal(100l, (long)r.Values[0]); + Assert.Equal(100, (long)r.Values[0]); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestCachedExecutionReadOnly() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -839,6 +856,7 @@ public void TestCachedExecutionReadOnly() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestSimpleReadOnly() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -854,6 +872,7 @@ public void TestSimpleReadOnly() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestProfile() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -872,6 +891,7 @@ public void TestProfile() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestExplain() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -890,6 +910,7 @@ public void TestExplain() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestSlowlog() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -905,6 +926,7 @@ public void TestSlowlog() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestList() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -918,6 +940,7 @@ public void TestList() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestConfig() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -934,10 +957,11 @@ public void TestConfig() Assert.Single(actual); Assert.Equal("250", actual[name].ToString()); - graph.ConfigSet(name, existingValue != null ? existingValue.ToString() : -1); + graph.ConfigSet(name, existingValue != null ? existingValue.ToString()! : -1); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestModulePrefixs() { IDatabase db1 = redisFixture.Redis.GetDatabase(); @@ -950,6 +974,7 @@ public void TestModulePrefixs() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestCallProcedureDbLabels() { var db = redisFixture.Redis.GetDatabase(); @@ -971,6 +996,7 @@ public void TestCallProcedureDbLabels() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestCallProcedureReadOnly() { var db = redisFixture.Redis.GetDatabase(); @@ -997,14 +1023,7 @@ public void TestCallProcedureReadOnly() #region AsyncTests [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] - public async Task TestReserveBasicAsync() - { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); - var graph = db.GRAPH(); - } - - [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestCreateNodeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1028,6 +1047,7 @@ public async Task TestCreateNodeAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestCreateLabeledNodeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1049,6 +1069,7 @@ public async Task TestCreateLabeledNodeAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestConnectNodesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1077,6 +1098,7 @@ public async Task TestConnectNodesAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestDeleteNodesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1124,6 +1146,7 @@ public async Task TestDeleteNodesAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestDeleteRelationshipAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1154,6 +1177,7 @@ public async Task TestDeleteRelationshipAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestIndexAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1181,6 +1205,7 @@ public async Task TestIndexAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestHeaderAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1194,7 +1219,7 @@ public async Task TestHeaderAsync() ResultSet queryResult = await graph.QueryAsync("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r, a.age"); - Header header = queryResult.Header; + Header header = queryResult.Header!; Assert.NotNull(header); Assert.Equal("Header{" // + "schemaTypes=[COLUMN_SCALAR, COLUMN_SCALAR, COLUMN_SCALAR], " @@ -1212,6 +1237,7 @@ public async Task TestHeaderAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestRecordAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1339,6 +1365,7 @@ await graph.QueryAsync("social", "MATCH (a:person), (b:person) WHERE (a.name = ' } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestAdditionToProceduresAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1369,7 +1396,7 @@ public async Task TestAdditionToProceduresAsync() ResultSet resultSet = await graph.QueryAsync("social", "MATCH (a:person)-[r:knows]->(b:person) RETURN a,r"); Assert.NotNull(resultSet.Header); - Header header = resultSet.Header; + Header header = resultSet.Header!; List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); Assert.Equal(2, schemaNames.Count); @@ -1402,7 +1429,7 @@ public async Task TestAdditionToProceduresAsync() "MATCH (a:worker), (b:worker) WHERE (a.lastName = 'a' AND b.lastName='b') CREATE (a)-[:worksWith]->(b)")); resultSet = await graph.QueryAsync("social", "MATCH (a:worker)-[r:worksWith]->(b:worker) RETURN a,r"); Assert.NotNull(resultSet.Header); - header = resultSet.Header; + header = resultSet.Header!; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); Assert.Equal(2, schemaNames.Count); @@ -1419,6 +1446,7 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestEscapedQueryAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1438,6 +1466,7 @@ public async Task TestEscapedQueryAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestArraySupportAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1473,7 +1502,7 @@ public async Task TestArraySupportAsync() // check header Assert.NotNull(resultSet.Header); - Header header = resultSet.Header; + Header header = resultSet.Header!; List schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); @@ -1495,7 +1524,7 @@ public async Task TestArraySupportAsync() resultSet = await graph.QueryAsync("social", "MATCH(n) return collect(n) as x"); Assert.NotNull(resultSet.Header); - header = resultSet.Header; + header = resultSet.Header!; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); @@ -1518,7 +1547,7 @@ record = iterator.Current; resultSet = await graph.QueryAsync("social", "unwind([0,1,2]) as x return x"); Assert.NotNull(resultSet.Header); - header = resultSet.Header; + header = resultSet.Header!; schemaNames = header.SchemaNames; Assert.NotNull(schemaNames); @@ -1538,6 +1567,7 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestPathAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1590,6 +1620,7 @@ public async Task TestPathAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestNullGraphEntitiesAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1604,7 +1635,7 @@ public async Task TestNullGraphEntitiesAsync() Assert.True(iterator.MoveNext()); NRedisStack.Graph.Record record = iterator.Current; Assert.False(iterator.MoveNext()); - Assert.Equal(new List() { null, null, null }, record.Values); + Assert.Equal(new List() { null!, null!, null! }, record.Values); // Test a query that produces 2 records, with 2 null values in the second. resultSet = await graph.QueryAsync("social", "MATCH (a) OPTIONAL MATCH (a)-[e]->(b) RETURN a, e, b ORDER BY ID(a)"); @@ -1644,6 +1675,7 @@ record = resultSet.Skip(1).First(); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task Test64bitnumberAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1662,6 +1694,7 @@ public async Task Test64bitnumberAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestCachedExecutionAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1693,15 +1726,18 @@ public async Task TestCachedExecutionAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestMapDataTypeAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var graph = db.GRAPH(); - Dictionary expected = new Dictionary(); - expected.Add("a", (long)1); - expected.Add("b", "str"); - expected.Add("c", null); + Dictionary expected = new Dictionary + { + { "a", (long)1 }, + { "b", "str" }, + { "c", null! } + }; List d = new List(); d.Add((long)1); d.Add((long)2); @@ -1723,6 +1759,7 @@ public async Task TestMapDataTypeAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestGeoPointLatLonAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1737,6 +1774,7 @@ public async Task TestGeoPointLatLonAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestGeoPointLonLatAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1750,6 +1788,7 @@ public async Task TestGeoPointLonLatAsync() AssertTestGeoPoint(graph); } + [Obsolete] private async Task AssertTestGeoPointAsync(GraphCommands graph) { ResultSet results = await graph.QueryAsync("social", "MATCH (restaurant) RETURN restaurant"); @@ -1765,6 +1804,7 @@ private async Task AssertTestGeoPointAsync(GraphCommands graph) } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task timeoutArgumentAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1775,10 +1815,11 @@ public async Task timeoutArgumentAsync() var iterator = rs.GetEnumerator(); iterator.MoveNext(); var r = iterator.Current; - Assert.Equal(100l, (long)r.Values[0]); + Assert.Equal(100, (long)r.Values[0]); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestCachedExecutionReadOnlyAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1812,6 +1853,7 @@ public async Task TestCachedExecutionReadOnlyAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestSimpleReadOnlyAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1827,6 +1869,7 @@ public async Task TestSimpleReadOnlyAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestProfileAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1845,6 +1888,7 @@ public async Task TestProfileAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestExplainAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1863,6 +1907,7 @@ public async Task TestExplainAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestSlowlogAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1878,6 +1923,7 @@ public async Task TestSlowlogAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestListAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1891,6 +1937,7 @@ public async Task TestListAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestConfigAsync() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1907,22 +1954,11 @@ public async Task TestConfigAsync() Assert.Single(actual); Assert.Equal("250", actual[name].ToString()); - await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString() : -1); - } - - [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] - public async Task TestModulePrefixsAsync() - { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); - - var graph1 = db1.GRAPH(); - var graph2 = db2.GRAPH(); - - Assert.NotEqual(graph1.GetHashCode(), graph2.GetHashCode()); + await graph.ConfigSetAsync(name, existingValue != null ? existingValue.ToString()! : -1); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestCallProcedureDbLabelsAsync() { var db = redisFixture.Redis.GetDatabase(); @@ -1944,6 +1980,7 @@ public async Task TestCallProcedureDbLabelsAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestCallProcedureReadOnlyAsync() { var db = redisFixture.Redis.GetDatabase(); @@ -1966,6 +2003,7 @@ public async Task TestCallProcedureReadOnlyAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestParseInfinity() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1980,6 +2018,7 @@ public void TestParseInfinity() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestEqualsAndToString() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -1994,7 +2033,7 @@ public void TestEqualsAndToString() Assert.True(iterator2.MoveNext()); var record2 = iterator2.Current; - Assert.True(resultSet1.Header.Equals(resultSet1.Header)); + Assert.True(resultSet1.Header!.Equals(resultSet1.Header)); Assert.False(resultSet1.Header.Equals(resultSet2.Header)); Assert.False(resultSet1.Header.Equals(new object())); Assert.False(resultSet1.Header.Equals(null)); @@ -2031,22 +2070,22 @@ public void TestEqualsAndToString() - var path = new NRedisStack.Graph.DataTypes.Path(new List() { node1, node2 }, - new List() { edge1, edge2 }); - var pathCopy = new NRedisStack.Graph.DataTypes.Path(new List() { node1, node2 }, - new List() { edge1, edge2 }); - var path2 = new NRedisStack.Graph.DataTypes.Path(new List() { node1, node2 }, - new List() { edge1 }); + var path = new NRedisStack.Graph.DataTypes.Path(new List() { node1!, node2 }, + new List() { edge1!, edge2 }); + var pathCopy = new NRedisStack.Graph.DataTypes.Path(new List() { node1!, node2 }, + new List() { edge1!, edge2 }); + var path2 = new NRedisStack.Graph.DataTypes.Path(new List() { node1!, node2 }, + new List() { edge1! }); Assert.True(path.Equals(pathCopy)); Assert.True(path.Equals(path)); Assert.False(path.Equals(path2)); Assert.False(path.Equals(node1)); - Assert.True(record1.ToString() == "Record{values=Infinity}" || record1.ToString() == "Record{values=∞}"); + Assert.True(record1!.ToString() == "Record{values=Infinity}" || record1.ToString() == "Record{values=∞}"); Assert.NotEqual(record2.GetHashCode(), record1.GetHashCode()); - var node1String = node1.ToString(); - var edge1String = edge1.ToString(); + var node1String = node1!.ToString(); + var edge1String = edge1!.ToString(); var pathString = path.ToString(); var expectedNode1String = "Node{labels=[], id=1, propertyMap={}}"; var expectedEdge1String = "Edge{relationshipType='', source=0, destination=0, id=1, propertyMap={}}"; @@ -2057,6 +2096,7 @@ public void TestEqualsAndToString() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public void TestPrepareQuery() { const string return1Query = "RETURN 1"; @@ -2073,7 +2113,7 @@ public void TestPrepareQuery() Assert.Equal(return1QueryRecordString, res1.Single().ToString()); // handle null - var buildCommand2 = GraphCommandBuilder.Query("graph", return1Query, new Dictionary { { "a", null } }); + var buildCommand2 = GraphCommandBuilder.Query("graph", return1Query, new Dictionary { { "a", null! } }); var expectedPreparedQuery2 = $"CYPHER a=null {return1Query}"; Assert.Equal(expectedPreparedQuery2, buildCommand2.Args[1].ToString()!); var res2 = graph.Query("graph", buildCommand2.Args[1].ToString()!); diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 70294443..492acc12 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -12,11 +12,6 @@ public class JsonTests : AbstractNRedisStackTest, IDisposable private readonly string _testName = "JSON_TESTS"; public JsonTests(RedisFixture redisFixture) : base(redisFixture) { } - public void Dispose() - { - redisFixture.Redis.GetDatabase().KeyDelete(_testName); - } - [Fact] public void TestSetFromFile() { @@ -939,8 +934,8 @@ public void TestMultiPathGet() var key = keys[0]; commands.Set(key, "$", new { a = "hello", b = new { a = "world" } }); var res = commands.Get(key, new[] { "$..a", "$.b" }).ToString(); - var obj = JsonSerializer.Deserialize(res); - Assert.True(obj.ContainsKey("$..a")); + var obj = JsonSerializer.Deserialize(res!); + Assert.True(obj!.ContainsKey("$..a")); Assert.True(obj.ContainsKey("$.b")); if (obj["$..a"] is JsonArray arr) { @@ -963,8 +958,8 @@ public async Task TestMultiPathGetAsync() var key = keys[0]; await commands.SetAsync(key, "$", new { a = "hello", b = new { a = "world" } }); var res = (await commands.GetAsync(key, new[] { "$..a", "$.b" })).ToString(); - var obj = JsonSerializer.Deserialize(res); - Assert.True(obj.ContainsKey("$..a")); + var obj = JsonSerializer.Deserialize(res!); + Assert.True(obj!.ContainsKey("$..a")); Assert.True(obj.ContainsKey("$.b")); if (obj["$..a"] is JsonArray arr) { diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index 06dd7344..747f1ba1 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -12,7 +12,8 @@ public class PipelineTests : AbstractNRedisStackTest, IDisposable public PipelineTests(RedisFixture redisFixture) : base(redisFixture) { } [SkipIfRedis(Is.OSSCluster, Comparison.GreaterThanOrEqual, "7.1.242")] - public async Task TestModulsPipeline() + [Obsolete] + public void TestModulsPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); @@ -63,7 +64,8 @@ public async Task TestModulsPipeline() } [SkipIfRedis(Is.OSSCluster)] - public async Task TestModulsPipelineWithotGraph() + [Obsolete] + public void TestModulsPipelineWithotGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); @@ -110,16 +112,16 @@ public async Task TestModulsPipelineWithotGraph() } [SkipIfRedis(Is.OSSCluster)] - public async Task TestBloomPipeline() + public void TestBloomPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var pipeline = new Pipeline(db); - pipeline.Bf.ReserveAsync(key, 0.001, 100); + _ = pipeline.Bf.ReserveAsync(key, 0.001, 100); for (int i = 0; i < 1000; i++) { - pipeline.Bf.AddAsync(key, i.ToString()); + _ = pipeline.Bf.AddAsync(key, i.ToString()); } for (int i = 0; i < 100; i++) @@ -136,14 +138,14 @@ public async Task TestBloomPipeline() } [Fact] - public async Task TestJsonPipeline() + public void TestJsonPipeline() { IDatabase db = redisFixture.Redis.GetDatabase(); var pipeline = new Pipeline(db); pipeline.Db.ExecuteAsync("FLUSHALL"); string jsonPerson = JsonSerializer.Serialize(new Person { Name = "Shachar", Age = 23 }); - pipeline.Json.SetAsync("key", "$", jsonPerson); + _ = pipeline.Json.SetAsync("key", "$", jsonPerson); // var setResponse = pipeline.Json.SetAsync("key", "$", jsonPerson); var getResponse = pipeline.Json.GetAsync("key"); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index c088b26f..2a4ecbe3 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -237,18 +237,18 @@ public void TestAggregationsLoad() // load t1 var req = new AggregationRequest("*").Load(new FieldName("t1")); var res = ft.Aggregate("idx", req); - Assert.Equal("hello", res[0]["t1"].ToString()); + Assert.Equal("hello", res[0]!["t1"].ToString()); // load t2 req = new AggregationRequest("*").Load(new FieldName("t2")); res = ft.Aggregate("idx", req); - Assert.Equal("world", res[0]["t2"]); + Assert.Equal("world", res[0]!["t2"]); // load all req = new AggregationRequest("*").LoadAll(); res = ft.Aggregate("idx", req); - Assert.Equal("hello", res[0]["t1"].ToString()); - Assert.Equal("world", res[0]["t2"]); + Assert.Equal("hello", res[0]!["t1"].ToString()); + Assert.Equal("world", res[0]!["t2"]); } [SkipIfRedis(Is.OSSCluster)] @@ -265,18 +265,18 @@ public async Task TestAggregationsLoadAsync() // load t1 var req = new AggregationRequest("*").Load(new FieldName("t1")); var res = await ft.AggregateAsync("idx", req); - Assert.Equal("hello", res[0]["t1"].ToString()); + Assert.Equal("hello", res[0]!["t1"].ToString()); // load t2 req = new AggregationRequest("*").Load(new FieldName("t2")); res = await ft.AggregateAsync("idx", req); - Assert.Equal("world", res[0]["t2"]); + Assert.Equal("world", res[0]!["t2"]); // load all req = new AggregationRequest("*").LoadAll(); res = await ft.AggregateAsync("idx", req); - Assert.Equal("hello", res[0]["t1"].ToString()); - Assert.Equal("world", res[0]["t2"]); + Assert.Equal("hello", res[0]!["t1"].ToString()); + Assert.Equal("world", res[0]!["t2"]); } @@ -1250,8 +1250,8 @@ public void dropIndexDD() Assert.True(ft.DropIndex(index, true)); - RedisResult[] keys = (RedisResult[])db.Execute("KEYS", "*"); - Assert.True(keys.Length == 0); + RedisResult[] keys = (RedisResult[])db.Execute("KEYS", "*")!; + Assert.Empty(keys); Assert.Equal("0", db.Execute("DBSIZE").ToString()); } @@ -1276,8 +1276,8 @@ public async Task dropIndexDDAsync() Assert.True(await ft.DropIndexAsync(index, true)); - RedisResult[] keys = (RedisResult[])db.Execute("KEYS", "*"); - Assert.True(keys.Length == 0); + RedisResult[] keys = (RedisResult[])db.Execute("KEYS", "*")!; + Assert.Empty(keys); Assert.Equal("0", db.Execute("DBSIZE").ToString()); } @@ -2045,7 +2045,7 @@ public async Task Test_ListAsync() } [Fact] - public async Task TestVectorCount_Issue70() + public void TestVectorCount_Issue70() { var schema = new Schema().AddVectorField("fieldTest", Schema.VectorField.VectorAlgo.HNSW, new Dictionary() { diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs index b2942779..804eda42 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs @@ -13,6 +13,7 @@ public TestAdd(RedisFixture redisFixture) : base(redisFixture) { } [Fact] + [Obsolete] public void TestAddNotExistingTimeSeries() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -27,6 +28,7 @@ public void TestAddNotExistingTimeSeries() } [Fact] + [Obsolete] public void TestAddExistingTimeSeries() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -42,6 +44,7 @@ public void TestAddExistingTimeSeries() } [Fact] + [Obsolete] public void TestAddStar() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -50,11 +53,12 @@ public void TestAddStar() ts.Add(key, "*", 1.1); TimeSeriesInformation info = ts.Info(key); - Assert.True(info.FirstTimeStamp > 0); + Assert.True(info.FirstTimeStamp! > 0); Assert.Equal(info.FirstTimeStamp, info.LastTimeStamp); } [Fact] + [Obsolete] public void TestAddWithRetentionTime() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -70,6 +74,7 @@ public void TestAddWithRetentionTime() } [Fact] + [Obsolete] public void TestAddWithLabels() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -86,6 +91,7 @@ public void TestAddWithLabels() } [Fact] + [Obsolete] public void TestAddWithUncompressed() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -100,6 +106,7 @@ public void TestAddWithUncompressed() } [Fact] + [Obsolete] public void TestAddWithChunkSize() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index c26d7a78..281518b4 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -14,6 +14,7 @@ public TestAlter(RedisFixture redisFixture) : base(redisFixture) { } [Fact] + [Obsolete] public void TestAlterRetentionTime() { long retentionTime = 5000; @@ -27,6 +28,7 @@ public void TestAlterRetentionTime() } [Fact] + [Obsolete] public void TestAlterLabels() { TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); @@ -45,6 +47,7 @@ public void TestAlterLabels() } [Fact] + [Obsolete] public void TestAlterPolicyAndChunk() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs index 282356de..317235af 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs @@ -14,6 +14,7 @@ public TestCreate(RedisFixture redisFixture) : base(redisFixture) { } [Fact] + [Obsolete] public void TestCreateOK() { IDatabase db = redisFixture.Redis.GetDatabase(); @@ -24,6 +25,7 @@ public void TestCreateOK() } [Fact] + [Obsolete] public void TestCreateRetentionTime() { long retentionTime = 5000; @@ -36,6 +38,7 @@ public void TestCreateRetentionTime() } [Fact] + [Obsolete] public void TestCreateLabels() { TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); @@ -49,6 +52,7 @@ public void TestCreateLabels() } [Fact] + [Obsolete] public void TestCreateEmptyLabels() { var labels = new List(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs index 61d656e2..14e54e6c 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs @@ -20,7 +20,7 @@ public void TestDefaultDecrBy() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); } [Fact] @@ -31,7 +31,7 @@ public void TestStarDecrBy() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value, timestamp: "*") > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); } [Fact] @@ -47,6 +47,7 @@ public void TestDecrByTimeStamp() } [Fact] + [Obsolete] public void TestDefaultDecrByWithRetentionTime() { double value = 5.5; @@ -55,12 +56,13 @@ public void TestDefaultDecrByWithRetentionTime() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value, retentionTime: retentionTime) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); TimeSeriesInformation info = ts.Info(key); Assert.Equal(retentionTime, info.RetentionTime); } [Fact] + [Obsolete] public void TestDefaultDecrByWithLabels() { double value = 5.5; @@ -70,7 +72,7 @@ public void TestDefaultDecrByWithLabels() var ts = db.TS(); var labels = new List { label }; Assert.True(ts.DecrBy(key, -value, labels: labels) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); TimeSeriesInformation info = ts.Info(key); Assert.Equal(labels, info.Labels); } @@ -83,7 +85,7 @@ public void TestDefaultDecrByWithUncompressed() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value, uncompressed: true) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs index a7123ddf..7f8edf0a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs @@ -43,7 +43,7 @@ public void TestAddAndGet() var ts = db.TS(); ts.Create(key); ts.Add(key, now, 1.1); - TimeSeriesTuple actual = ts.Get(key); + TimeSeriesTuple actual = ts.Get(key)!; Assert.Equal(expected, actual); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs index ee1479d3..af1d35bf 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs @@ -20,7 +20,7 @@ public void TestDefaultIncrBy() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.IncrBy(key, value) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); } [Fact] @@ -31,7 +31,7 @@ public void TestStarIncrBy() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.IncrBy(key, value, timestamp: "*") > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); } [Fact] @@ -47,6 +47,7 @@ public void TestIncrByTimeStamp() } [Fact] + [Obsolete] public void TestDefaultIncrByWithRetentionTime() { double value = 5.5; @@ -55,12 +56,13 @@ public void TestDefaultIncrByWithRetentionTime() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.IncrBy(key, value, retentionTime: retentionTime) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); TimeSeriesInformation info = ts.Info(key); Assert.Equal(retentionTime, info.RetentionTime); } [Fact] + [Obsolete] public void TestDefaultIncrByWithLabels() { double value = 5.5; @@ -70,7 +72,7 @@ public void TestDefaultIncrByWithLabels() var ts = db.TS(); var labels = new List { label }; Assert.True(ts.IncrBy(key, value, labels: labels) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); TimeSeriesInformation info = ts.Info(key); Assert.Equal(labels, info.Labels); } @@ -83,7 +85,7 @@ public void TestDefaultIncrByWithUncompressed() db.Execute("FLUSHALL"); var ts = db.TS(); Assert.True(ts.IncrBy(key, value, uncompressed: true) > 0); - Assert.Equal(value, ts.Get(key).Val); + Assert.Equal(value, ts.Get(key)!.Val); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs index cba16e34..4acf5547 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs @@ -14,6 +14,7 @@ public class TestMADD : AbstractNRedisStackTest, IDisposable public TestMADD(RedisFixture redisFixture) : base(redisFixture) { } [SkipIfRedis(Is.OSSCluster)] + [Obsolete] public void TestStarMADD() { @@ -37,7 +38,7 @@ public void TestStarMADD() foreach (var key in keys) { TimeSeriesInformation info = ts.Info(key); - Assert.True(info.FirstTimeStamp > 0); + Assert.True(info.FirstTimeStamp! > 0); Assert.Equal(info.FirstTimeStamp, info.LastTimeStamp); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs index 78ef509b..5bc4b04a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs @@ -12,6 +12,7 @@ public TestMAddAsync(RedisFixture redisFixture) : base(redisFixture) { } [SkipIfRedis(Is.OSSCluster)] + [Obsolete] public async Task TestStarMADD() { var keys = CreateKeyNames(2); @@ -37,7 +38,7 @@ public async Task TestStarMADD() foreach (var key in keys) { TimeSeriesInformation info = await ts.InfoAsync(key); - Assert.True(info.FirstTimeStamp > 0); + Assert.True(info.FirstTimeStamp! > 0); Assert.Equal(info.FirstTimeStamp, info.LastTimeStamp); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs index fe30f5cd..82ff0183 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs @@ -33,6 +33,7 @@ public TestRules(RedisFixture redisFixture) : base(redisFixture) } [SkipIfRedis(Is.OSSCluster)] + [Obsolete] public void TestRulesAdditionDeletion() { IDatabase db = redisFixture.Redis.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs index e024bec8..b7cb6455 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs @@ -11,6 +11,7 @@ public class TestRulesAsync : AbstractNRedisStackTest public TestRulesAsync(RedisFixture redisFixture) : base(redisFixture) { } [SkipIfRedis(Is.OSSCluster)] + [Obsolete] public async Task TestRulesAdditionDeletion() { var key = CreateKeyName(); diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 26ed80e3..6c91c9c2 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -58,7 +58,7 @@ public async Task CreateTopKFilterAsync() await topk.ReserveAsync(key, 30, 2000, 7, 0.925); var res = await topk.AddAsync(key, "bb", "cc"); - Assert.True(res[0].IsNull && res[1].IsNull); + Assert.True(res![0].IsNull && res[1].IsNull); Assert.Equal(await topk.QueryAsync(key, "bb", "gg", "cc"), new bool[] { true, false, true }); Assert.False(await topk.QueryAsync(key, "notExists")); diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 791fe618..1f7b9603 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -13,7 +13,7 @@ public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { } [Fact] - public async Task TestJsonTransaction() + public void TestJsonTransaction() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); @@ -29,22 +29,23 @@ public async Task TestJsonTransaction() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [Obsolete] public async Task TestModulsTransaction() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var tran = new Transaction(db); - tran.Bf.ReserveAsync("bf-key", 0.001, 100); - tran.Bf.AddAsync("bf-key", "1"); - tran.Cms.InitByDimAsync("cms-key", 100, 5); - tran.Cf.ReserveAsync("cf-key", 100); - tran.Graph.QueryAsync("graph-key", "CREATE ({name:'shachar',age:23})"); - tran.Json.SetAsync("json-key", "$", "{}"); - tran.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); - tran.Tdigest.CreateAsync("tdigest-key", 100); - tran.Ts.CreateAsync("ts-key", 100); - tran.TopK.ReserveAsync("topk-key", 100, 100, 100); + await tran.Bf.ReserveAsync("bf-key", 0.001, 100); + await tran.Bf.AddAsync("bf-key", "1"); + await tran.Cms.InitByDimAsync("cms-key", 100, 5); + await tran.Cf.ReserveAsync("cf-key", 100); + await tran.Graph.QueryAsync("graph-key", "CREATE ({name:'shachar',age:23})"); + await tran.Json.SetAsync("json-key", "$", "{}"); + await tran.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); + await tran.Tdigest.CreateAsync("tdigest-key", 100); + await tran.Ts.CreateAsync("ts-key", 100); + await tran.TopK.ReserveAsync("topk-key", 100, 100, 100); Assert.False(db.KeyExists("bf-key")); Assert.False(db.KeyExists("cms-key")); From 2c5dab60b66e0e77f2a09ee7097ce39e1278f42d Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 10:31:42 +0300 Subject: [PATCH 46/48] fix more warnings --- tests/NRedisStack.Tests/Examples/ExampleTests.cs | 2 +- tests/NRedisStack.Tests/Gears/GearsTests.cs | 2 +- tests/NRedisStack.Tests/Graph/GraphTests.cs | 2 +- tests/NRedisStack.Tests/Json/JsonTests.cs | 2 +- .../NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs | 1 + .../TimeSeries/TestAPI/TestDecrByAsync.cs | 8 +++++--- tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index f788f4af..be3f2ca7 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -20,7 +20,7 @@ namespace NRedisStack.Tests; public class ExampleTests : AbstractNRedisStackTest, IDisposable { private readonly ITestOutputHelper testOutputHelper; - private readonly string key = "EXAMPLES_TESTS"; + // private readonly string key = "EXAMPLES_TESTS"; public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelper) : base(redisFixture) { this.testOutputHelper = testOutputHelper; diff --git a/tests/NRedisStack.Tests/Gears/GearsTests.cs b/tests/NRedisStack.Tests/Gears/GearsTests.cs index 16074dbf..e4c5e7bb 100644 --- a/tests/NRedisStack.Tests/Gears/GearsTests.cs +++ b/tests/NRedisStack.Tests/Gears/GearsTests.cs @@ -5,7 +5,7 @@ namespace NRedisStack.Tests.Gears; public class GearsTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "GEARS_TESTS"; + // private readonly string key = "GEARS_TESTS"; public GearsTests(RedisFixture redisFixture) : base(redisFixture) { } [SkipIfRedis(Comparison.LessThan, "7.1.242")] diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index b9dae8f7..10a6e6b3 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -8,7 +8,7 @@ namespace NRedisStack.Tests.Graph; public class GraphTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "GRAPH_TESTS"; + // private readonly string key = "GRAPH_TESTS"; public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } #region SyncTests diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 492acc12..36b8fa3a 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 : AbstractNRedisStackTest, IDisposable { - private readonly string _testName = "JSON_TESTS"; + // private readonly string _testName = "JSON_TESTS"; public JsonTests(RedisFixture redisFixture) : base(redisFixture) { } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs index c7ec525d..d0a77c4b 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs @@ -90,6 +90,7 @@ public async Task TestAddWithLabels() } [Fact] + [Obsolete] public async Task TestAddWithChunkSize() { var key = CreateKeyName(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs index 87a29974..463f69d6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs @@ -51,6 +51,7 @@ public async Task TestDecrByTimeStamp() } [Fact] + [Obsolete] public async Task TestDefaultDecrByWithRetentionTime() { var key = CreateKeyName(); @@ -62,13 +63,14 @@ public async Task TestDefaultDecrByWithRetentionTime() Assert.True(await ts.DecrByAsync(key, -value, retentionTime: retentionTime) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); var info = await ts.InfoAsync(key); Assert.Equal(retentionTime, info.RetentionTime); } [Fact] + [Obsolete] public async Task TestDefaultDecrByWithLabels() { var key = CreateKeyName(); @@ -81,7 +83,7 @@ public async Task TestDefaultDecrByWithLabels() Assert.True(await ts.DecrByAsync(key, -value, labels: labels) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); var info = await ts.InfoAsync(key); Assert.Equal(labels, info.Labels); @@ -98,7 +100,7 @@ public async Task TestDefaultDecrByWithUncompressed() Assert.True(await ts.DecrByAsync(key, -value, uncompressed: true) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs index 6874fa83..cf7615a8 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs @@ -7,7 +7,7 @@ namespace NRedisStack.Tests.TimeSeries; public class TimeSeriesTests : AbstractNRedisStackTest, IDisposable { - private readonly string key = "TIME_SERIES_TESTS"; + // private readonly string key = "TIME_SERIES_TESTS"; public TimeSeriesTests(RedisFixture redisFixture) : base(redisFixture) { } // [Fact] From c3c369d13dd1b15a147bde86c89ec63a9b0c7818 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 11:27:24 +0300 Subject: [PATCH 47/48] clean almost all warnings --- src/NRedisStack/Graph/ResultSet.cs | 8 ++++++++ src/NRedisStack/Search/Group.cs | 2 +- tests/NRedisStack.Tests/Person.cs | 2 +- .../TimeSeries/TestAPI/TestAddAsync.cs | 8 +++++++- .../TimeSeries/TestAPI/TestAlterAsync.cs | 3 +++ .../TimeSeries/TestAPI/TestCreateAsync.cs | 3 +++ .../TimeSeries/TestAPI/TestDecrByAsync.cs | 4 ++-- .../TimeSeries/TestAPI/TestIncrByAsync.cs | 12 +++++++----- .../TestTimeSeriesInformation.cs | 2 ++ tests/NRedisStack.Tests/TransactionsTests.cs | 19 ++++++++++--------- 10 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/NRedisStack/Graph/ResultSet.cs b/src/NRedisStack/Graph/ResultSet.cs index 45291286..9ef95af8 100644 --- a/src/NRedisStack/Graph/ResultSet.cs +++ b/src/NRedisStack/Graph/ResultSet.cs @@ -32,6 +32,7 @@ internal enum ResultSetScalarType public Header? Header { get; } public int Count { get; } + [Obsolete] internal ResultSet(RedisResult result, GraphCache graphCache) { if (result.Type == ResultType.MultiBulk) @@ -125,6 +126,7 @@ private IEnumerable RecordIterator() } } + [Obsolete] private Node DeserializeNode(RedisResult[] rawNodeData) { var node = new Node(); @@ -145,6 +147,7 @@ private Node DeserializeNode(RedisResult[] rawNodeData) return node; } + [Obsolete] private Edge DeserializeEdge(RedisResult[] rawEdgeData) { var edge = new Edge(); @@ -160,6 +163,7 @@ private Edge DeserializeEdge(RedisResult[] rawEdgeData) return edge; } + [Obsolete] private object? DeserializeScalar(RedisResult[] rawScalarData) { var type = GetValueTypeFromObject(rawScalarData[0]); @@ -197,6 +201,7 @@ private Edge DeserializeEdge(RedisResult[] rawEdgeData) private static void DeserializeGraphEntityId(GraphEntity graphEntity, RedisResult rawEntityId) => graphEntity.Id = (int)rawEntityId; + [Obsolete] private void DeserializeGraphEntityProperties(GraphEntity graphEntity, RedisResult[] rawProperties) { foreach (RedisResult[]? rawProperty in rawProperties) @@ -209,6 +214,7 @@ private void DeserializeGraphEntityProperties(GraphEntity graphEntity, RedisResu } } + [Obsolete] private object[] DeserializeArray(RedisResult[] serializedArray) { var result = new object[serializedArray.Length]; @@ -221,6 +227,7 @@ private object[] DeserializeArray(RedisResult[] serializedArray) return result; } + [Obsolete] private DataTypes.Path DeserializePath(RedisResult[] rawPath) { var deserializedNodes = (object[])DeserializeScalar((RedisResult[])rawPath[0]!)!; @@ -248,6 +255,7 @@ private DataTypes.Path DeserializePath(RedisResult[] rawPath) } // @SuppressWarnings("unchecked") + [Obsolete] private Dictionary DeserializeDictionary(RedisResult rawPath) { RedisResult[] keyTypeValueEntries = (RedisResult[])rawPath!; diff --git a/src/NRedisStack/Search/Group.cs b/src/NRedisStack/Search/Group.cs index 04ffb321..a45e065f 100644 --- a/src/NRedisStack/Search/Group.cs +++ b/src/NRedisStack/Search/Group.cs @@ -36,7 +36,7 @@ internal void SerializeRedisArgs(List args) if (!string.IsNullOrEmpty(alias)) { args.Add("AS"); - args.Add(alias); + args.Add(alias!); } } _limit.SerializeRedisArgs(args); diff --git a/tests/NRedisStack.Tests/Person.cs b/tests/NRedisStack.Tests/Person.cs index 6859401b..fc217a05 100644 --- a/tests/NRedisStack.Tests/Person.cs +++ b/tests/NRedisStack.Tests/Person.cs @@ -2,7 +2,7 @@ namespace NRedisStack.Tests { public class Person { - public string Name { get; set; } + public string? Name { get; set; } public int Age { get; set; } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs index d0a77c4b..7e641ab3 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs @@ -11,6 +11,7 @@ public class TestAddAsync : AbstractNRedisStackTest public TestAddAsync(RedisFixture redisFixture) : base(redisFixture) { } [Fact] + [Obsolete] public async Task TestAddNotExistingTimeSeries() { var key = CreateKeyName(); @@ -26,6 +27,7 @@ public async Task TestAddNotExistingTimeSeries() } [Fact] + [Obsolete] public async Task TestAddExistingTimeSeries() { var key = CreateKeyName(); @@ -42,6 +44,7 @@ public async Task TestAddExistingTimeSeries() } [Fact] + [Obsolete] public async Task TestAddStar() { var key = CreateKeyName(); @@ -50,11 +53,12 @@ public async Task TestAddStar() var ts = db.TS(); await ts.AddAsync(key, "*", 1.1); var info = await ts.InfoAsync(key); - Assert.True(info.FirstTimeStamp > 0); + Assert.True(info.FirstTimeStamp! > 0); Assert.Equal(info.FirstTimeStamp, info.LastTimeStamp); } [Fact] + [Obsolete] public async Task TestAddWithRetentionTime() { var key = CreateKeyName(); @@ -72,6 +76,7 @@ public async Task TestAddWithRetentionTime() } [Fact] + [Obsolete] public async Task TestAddWithLabels() { var key = CreateKeyName(); @@ -106,6 +111,7 @@ public async Task TestAddWithChunkSize() } [Fact] + [Obsolete] public async Task TestAddWithUncompressed() { var key = CreateKeyName(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs index 05a992ce..ff5df550 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs @@ -10,6 +10,7 @@ public class TestAlterAsync : AbstractNRedisStackTest public TestAlterAsync(RedisFixture redisFixture) : base(redisFixture) { } [Fact] + [Obsolete] public async Task TestAlterRetentionTime() { var key = CreateKeyName(); @@ -25,6 +26,7 @@ public async Task TestAlterRetentionTime() } [Fact] + [Obsolete] public async Task TestAlterLabels() { var key = CreateKeyName(); @@ -47,6 +49,7 @@ public async Task TestAlterLabels() } [Fact] + [Obsolete] public async Task TestAlterPolicyAndChunkAsync() { var key = CreateKeyName(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs index 39b1951f..36993d4b 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs @@ -20,6 +20,7 @@ public async Task TestCreateOK() } [Fact] + [Obsolete] public async Task TestCreateRetentionTime() { var key = CreateKeyName(); @@ -34,6 +35,7 @@ public async Task TestCreateRetentionTime() } [Fact] + [Obsolete] public async Task TestCreateLabels() { var key = CreateKeyName(); @@ -49,6 +51,7 @@ public async Task TestCreateLabels() } [Fact] + [Obsolete] public async Task TestCreateEmptyLabels() { var key = CreateKeyName(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs index 463f69d6..219ebe64 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs @@ -20,7 +20,7 @@ public async Task TestDefaultDecrBy() Assert.True(await ts.DecrByAsync(key, -value) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); } [Fact] @@ -34,7 +34,7 @@ public async Task TestStarDecrBy() Assert.True(await ts.DecrByAsync(key, -value, timestamp: "*") > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs index 2ca85069..1c02440e 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs @@ -20,7 +20,7 @@ public async Task TestDefaultIncrBy() Assert.True(await ts.IncrByAsync(key, value) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); } [Fact] @@ -34,7 +34,7 @@ public async Task TestStarIncrBy() Assert.True(await ts.IncrByAsync(key, value, timestamp: "*") > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); } [Fact] @@ -51,6 +51,7 @@ public async Task TestIncrByTimeStamp() } [Fact] + [Obsolete] public async Task TestDefaultIncrByWithRetentionTime() { var key = CreateKeyName(); @@ -62,13 +63,14 @@ public async Task TestDefaultIncrByWithRetentionTime() Assert.True(await ts.IncrByAsync(key, value, retentionTime: retentionTime) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); var info = await ts.InfoAsync(key); Assert.Equal(retentionTime, info.RetentionTime); } [Fact] + [Obsolete] public async Task TestDefaultIncrByWithLabels() { var key = CreateKeyName(); @@ -81,7 +83,7 @@ public async Task TestDefaultIncrByWithLabels() Assert.True(await ts.IncrByAsync(key, value, labels: labels) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); var info = await ts.InfoAsync(key); Assert.Equal(labels, info.Labels); @@ -98,7 +100,7 @@ public async Task TestDefaultIncrByWithUncompressed() Assert.True(await ts.IncrByAsync(key, value, uncompressed: true) > 0); var result = await ts.GetAsync(key); - Assert.Equal(value, result.Val); + Assert.Equal(value, result!.Val); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs index 9318fd07..e3e43daa 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs @@ -13,6 +13,7 @@ public class TestInformation : AbstractNRedisStackTest public TestInformation(NRedisStack.Tests.RedisFixture redisFixture) : base(redisFixture) { } [Fact] + [Obsolete] public void TestInformationSync() { string key = CreateKeyName(); @@ -41,6 +42,7 @@ public void TestInformationSync() } [Fact] + [Obsolete] public async Task TestInformationAsync() { string key = CreateKeyName(); diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 1f7b9603..0422dca4 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -81,21 +81,22 @@ public async Task TestModulsTransaction() } [SkipIfRedis(Is.OSSCluster)] + [Obsolete] public async Task TestModulsTransactionWithoutGraph() { IDatabase db = redisFixture.Redis.GetDatabase(); db.Execute("FLUSHALL"); var tran = new Transaction(db); - tran.Bf.ReserveAsync("bf-key", 0.001, 100); - tran.Bf.AddAsync("bf-key", "1"); - tran.Cms.InitByDimAsync("cms-key", 100, 5); - tran.Cf.ReserveAsync("cf-key", 100); - tran.Json.SetAsync("json-key", "$", "{}"); - tran.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); - tran.Tdigest.CreateAsync("tdigest-key", 100); - tran.Ts.CreateAsync("ts-key", 100); - tran.TopK.ReserveAsync("topk-key", 100, 100, 100); + await tran.Bf.ReserveAsync("bf-key", 0.001, 100); + await tran.Bf.AddAsync("bf-key", "1"); + await tran.Cms.InitByDimAsync("cms-key", 100, 5); + await tran.Cf.ReserveAsync("cf-key", 100); + await tran.Json.SetAsync("json-key", "$", "{}"); + await tran.Ft.CreateAsync("ft-key", new FTCreateParams(), new Schema().AddTextField("txt")); + await tran.Tdigest.CreateAsync("tdigest-key", 100); + await tran.Ts.CreateAsync("ts-key", 100); + await tran.TopK.ReserveAsync("topk-key", 100, 100, 100); Assert.False(db.KeyExists("bf-key")); Assert.False(db.KeyExists("cms-key")); From 1ca4abbb2a1f40bae83535bfbacb505e11bc1a74 Mon Sep 17 00:00:00 2001 From: shacharPash Date: Wed, 27 Sep 2023 11:36:04 +0300 Subject: [PATCH 48/48] hope its all --- src/NRedisStack/Graph/Header.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/NRedisStack/Graph/Header.cs b/src/NRedisStack/Graph/Header.cs index 9263a3bf..506a84d1 100644 --- a/src/NRedisStack/Graph/Header.cs +++ b/src/NRedisStack/Graph/Header.cs @@ -42,6 +42,7 @@ internal Header(RedisResult result) } } +#pragma warning disable CS0809 [Obsolete] public override bool Equals(object? obj) { @@ -79,4 +80,5 @@ public override int GetHashCode() public override string ToString() => $"Header{{schemaTypes=[{string.Join(", ", SchemaTypes)}], schemaNames=[{string.Join(", ", SchemaNames)}]}}"; } +#pragma warning restore CS0809 } \ No newline at end of file