From f5cce98cb80fdd582487beaebcf96a716c861655 Mon Sep 17 00:00:00 2001 From: shacharPash <93581407+shacharPash@users.noreply.github.com> Date: Mon, 14 Aug 2023 17:05:08 +0300 Subject: [PATCH] Removing Moq as a dependency for mock unit tests (#168) * delete mock * coverage * fix test * indent * change to var - check --- tests/NRedisStack.Tests/Bloom/BloomTests.cs | 2 - .../CountMinSketch/CmsTests.cs | 2 - .../CuckooFilter/CuckooTests.cs | 2 - .../Examples/ExampleTests.cs | 2 - tests/NRedisStack.Tests/Gears/GearsTests.cs | 2 - tests/NRedisStack.Tests/Graph/GraphTests.cs | 2 - tests/NRedisStack.Tests/Json/JsonTests.cs | 129 ++++++++++-------- .../NRedisStack.Tests.csproj | 1 - tests/NRedisStack.Tests/PipelineTests.cs | 2 - tests/NRedisStack.Tests/Search/SearchTests.cs | 2 - .../NRedisStack.Tests/Tdigest/TdigestTests.cs | 2 - .../TimeSeries/TimeSeriesTests.cs | 2 - tests/NRedisStack.Tests/TopK/TopKTests.cs | 2 - tests/NRedisStack.Tests/TransactionsTests.cs | 4 +- 14 files changed, 75 insertions(+), 81 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 465a65ff..9651f53e 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 b7a49c03..05df345f 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 1ad5ef8a..2fd6f74b 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) { } @@ -25,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: @@ -53,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]; @@ -103,10 +101,31 @@ public void TestSetFromDirectory() [Fact] public void TestJsonSetNotExist() { + //arrange + var conn = redisFixture.Redis; + var db = conn.GetDatabase(); + var 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.True(commands.Set("Person:Shachar", "$", obj, When.Exists)); + } + + [Fact] + public async Task TestJsonSetNotExistAsync() + { + //arrange + var conn = redisFixture.Redis; + var db = conn.GetDatabase(); + var commands = new JsonCommands(db); + db.Execute("FLUSHALL"); + 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")); + Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); + Assert.False(await commands.SetAsync("Person:Shachar", "$", obj, When.NotExists)); + Assert.True(await commands.SetAsync("Person:Shachar", "$", obj, When.Exists)); } [Fact] @@ -127,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]; @@ -152,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]; @@ -177,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]; @@ -205,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]; @@ -233,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]; @@ -258,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]; @@ -283,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]; @@ -305,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]; @@ -327,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]; @@ -351,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]; @@ -374,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]; @@ -392,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]; @@ -410,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" } } }); @@ -424,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" } } }); @@ -436,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]; @@ -453,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]; @@ -470,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]; @@ -486,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]; @@ -502,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]; @@ -520,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]; @@ -538,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]; @@ -554,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]; @@ -570,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]; @@ -586,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]; @@ -602,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]; @@ -618,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]; @@ -634,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]; @@ -650,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]; @@ -666,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]; @@ -686,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]; @@ -706,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]; @@ -730,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]; @@ -754,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 } })); @@ -773,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 } })); @@ -791,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]; @@ -806,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]; @@ -821,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" } }); @@ -834,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" } }); @@ -847,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 } }); @@ -865,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 } }); @@ -883,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 } }); @@ -899,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 } }); @@ -915,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" } }); @@ -939,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" } }); @@ -963,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]; @@ -977,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]; @@ -994,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: @@ -1022,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]; 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 37ed8dcf..0100faad 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 f89a8191..26f3d8aa 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,7 +8,6 @@ namespace NRedisStack.Tests { public class TransactionTests : AbstractNRedisStackTest, IDisposable { - Mock _mock = new Mock(); private readonly string key = "TRX_TESTS"; public TransactionTests(RedisFixture redisFixture) : base(redisFixture) { }