diff --git a/.gitignore b/.gitignore index b67a9384..2476cd6b 100644 --- a/.gitignore +++ b/.gitignore @@ -382,6 +382,7 @@ FodyWeavers.xsd !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +!.vscode/.runsettings *.code-workspace # Local History for Visual Studio Code diff --git a/.vscode/.runsettings b/.vscode/.runsettings new file mode 100644 index 00000000..7409817f --- /dev/null +++ b/.vscode/.runsettings @@ -0,0 +1,10 @@ + + + + + + + 7.4.0 + + + diff --git a/.vscode/settings.json b/.vscode/settings.json index 079dbf34..12b5a010 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info", "dotnet-test-explorer.testProjectPath": "**/*NRedisStack.Tests.csproj", - "dotnet.defaultSolution": "NRedisStack.sln" + "dotnet.defaultSolution": "NRedisStack.sln", + "dotnet.unitTests.runSettingsPath": ".vscode/.runsettings" } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index a9c684b1..9f5c3380 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -239,7 +239,7 @@ public void TestInfo(string endpointId) var info = bf.Info(key); Assert.NotNull(info); - Assert.Equal(info.NumberOfItemsInserted, (long)1); + Assert.Equal((long)1, info.NumberOfItemsInserted); Assert.Throws(() => bf.Info("notExistKey")); } @@ -255,7 +255,7 @@ public async Task TestInfoAsync(string endpointId) var info = await bf.InfoAsync(key); Assert.NotNull(info); - Assert.Equal(info.NumberOfItemsInserted, (long)1); + Assert.Equal((long)1, info.NumberOfItemsInserted); await Assert.ThrowsAsync(() => bf.InfoAsync("notExistKey")); } diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 545548d4..8e60716e 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -192,14 +192,14 @@ public void TestInfo(string endpointId) var info = cf.Info(key); Assert.NotNull(info); - Assert.Equal(info.BucketSize, (long)2); - Assert.Equal(info.ExpansionRate, (long)1); - Assert.Equal(info.MaxIterations, (long)20); - Assert.Equal(info.NumberOfBuckets, (long)512); - Assert.Equal(info.NumberOfFilters, (long)1); - Assert.Equal(info.NumberOfItemsDeleted, (long)0); - Assert.Equal(info.NumberOfItemsInserted, (long)1); - Assert.Equal(info.Size, (long)1080); + Assert.Equal((long)2, info.BucketSize); + Assert.Equal((long)1, info.ExpansionRate); + Assert.Equal((long)20, info.MaxIterations); + Assert.Equal((long)512, info.NumberOfBuckets); + Assert.Equal((long)1, info.NumberOfFilters); + Assert.Equal((long)0, info.NumberOfItemsDeleted); + Assert.Equal((long)1, info.NumberOfItemsInserted); + Assert.Equal((long)1080, info.Size); Assert.Throws(() => cf.Info("notExistKey")); } @@ -215,14 +215,14 @@ public async Task TestInfoAsync(string endpointId) var info = await cf.InfoAsync(key); Assert.NotNull(info); - Assert.Equal(info.BucketSize, (long)2); - Assert.Equal(info.ExpansionRate, (long)1); - Assert.Equal(info.MaxIterations, (long)20); - Assert.Equal(info.NumberOfBuckets, (long)512); - Assert.Equal(info.NumberOfFilters, (long)1); - Assert.Equal(info.NumberOfItemsDeleted, (long)0); - Assert.Equal(info.NumberOfItemsInserted, (long)1); - Assert.Equal(info.Size, (long)1080); + Assert.Equal((long)2, info.BucketSize); + Assert.Equal((long)1, info.ExpansionRate); + Assert.Equal((long)20, info.MaxIterations); + Assert.Equal((long)512, info.NumberOfBuckets); + Assert.Equal((long)1, info.NumberOfFilters); + Assert.Equal((long)0, info.NumberOfItemsDeleted); + Assert.Equal((long)1, info.NumberOfItemsInserted); + Assert.Equal((long)1080, info.Size); diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index 148f4548..98a988d3 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -225,7 +225,7 @@ public async Task PipelineWithAsync(string endpointId) selectedLabels: new List { "location" }); // Assert the response - Assert.Equal(1, response.Count); + Assert.Single(response); Assert.Equal("temp:JLM", response[0].key); } diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 6444ab23..2532e0fc 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -990,7 +990,7 @@ public void TestMultiPathGet(string endpointId) } else { - Assert.True(false, "$..a was not a json array"); + Assert.Fail("$..a was not a json array"); } Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world"); @@ -1015,7 +1015,7 @@ public async Task TestMultiPathGetAsync(string endpointId) } else { - Assert.True(false, "$..a was not a json array"); + Assert.Fail("$..a was not a json array"); } Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world"); diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 4dcd036a..1984cb6b 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -2170,7 +2170,7 @@ public void TestLimit(string endpointId) var req = new AggregationRequest("*").SortBy("@t1").Limit(1); var res = ft.Aggregate("idx", req); - Assert.Equal(1, res.GetResults().Count); + Assert.Single(res.GetResults()); Assert.Equal("a", res.GetResults()[0]["t1"].ToString()); } @@ -2190,7 +2190,7 @@ public async Task TestLimitAsync(string endpointId) var req = new AggregationRequest("*").SortBy("@t1").Limit(1, 1); var res = await ft.AggregateAsync("idx", req); - Assert.Equal(1, res.GetResults().Count); + Assert.Single(res.GetResults()); Assert.Equal("b", res.GetResults()[0]["t1"].ToString()); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs index b29f6773..0794705f 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs @@ -228,8 +228,8 @@ public void TestAddAndIgnoreValues(string endpointId) RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k); Assert.NotNull(info); Assert.True(info.Length > 0); - Assert.NotEqual(j, -1); - Assert.NotEqual(k, -1); + Assert.NotEqual(-1, j); + Assert.NotEqual(-1, k); Assert.Equal(15, (long)info[j + 1]); Assert.Equal(16, (long)info[k + 1]); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index 526e9585..5177e5ca 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -73,8 +73,8 @@ public void TestAlterAndIgnoreValues(string endpointId) RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k); Assert.NotNull(info); Assert.True(info.Length > 0); - Assert.NotEqual(j, -1); - Assert.NotEqual(k, -1); + Assert.NotEqual(-1, j); + Assert.NotEqual(-1, k); Assert.Equal(13, (long)info[j + 1]); Assert.Equal(14, (long)info[k + 1]); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs index ae1b873d..698f00bf 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs @@ -122,8 +122,8 @@ public void TestCreateAndIgnoreValues(string endpointId) int j = -1, k = -1; RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k); - Assert.NotEqual(j, -1); - Assert.NotEqual(k, -1); + Assert.NotEqual(-1, j); + Assert.NotEqual(-1, k); Assert.Equal(11, (long)info[j + 1]); Assert.Equal(12, (long)info[k + 1]); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs index be6c707a..feb9562b 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs @@ -71,7 +71,7 @@ public async Task TestCreateUncompressed() } [Fact] - public async void TestCreatehDuplicatePolicyFirst() + public async Task TestCreatehDuplicatePolicyFirst() { var key = CreateKeyName(); var db = GetCleanDatabase(); @@ -80,7 +80,7 @@ public async void TestCreatehDuplicatePolicyFirst() } [Fact] - public async void TestCreatehDuplicatePolicyLast() + public async Task TestCreatehDuplicatePolicyLast() { var key = CreateKeyName(); var db = GetCleanDatabase(); @@ -89,7 +89,7 @@ public async void TestCreatehDuplicatePolicyLast() } [Fact] - public async void TestCreatehDuplicatePolicyMin() + public async Task TestCreatehDuplicatePolicyMin() { var key = CreateKeyName(); var db = GetCleanDatabase(); @@ -98,7 +98,7 @@ public async void TestCreatehDuplicatePolicyMin() } [Fact] - public async void TestCreatehDuplicatePolicyMax() + public async Task TestCreatehDuplicatePolicyMax() { var key = CreateKeyName(); var db = GetCleanDatabase(); @@ -107,7 +107,7 @@ public async void TestCreatehDuplicatePolicyMax() } [Fact] - public async void TestCreatehDuplicatePolicySum() + public async Task TestCreatehDuplicatePolicySum() { var key = CreateKeyName(); var db = GetCleanDatabase(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs index 8888714a..b024015b 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs @@ -109,8 +109,8 @@ public async void TestIncrDecryByAndIgnoreValues(string endpointId) RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k); Assert.NotNull(info); Assert.True(info.Length > 0); - Assert.NotEqual(j, -1); - Assert.NotEqual(k, -1); + Assert.NotEqual(-1, j); + Assert.NotEqual(-1, k); Assert.Equal(15, (long)info[j + 1]); Assert.Equal(16, (long)info[k + 1]); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs index 4cf7f140..609686c1 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs @@ -45,7 +45,7 @@ public void TestDelRange() // check that the operation deleted the timestamps IReadOnlyList res = ts.Range(key, from, to); - Assert.Equal(0, res.Count); + Assert.Empty(res); Assert.NotNull(ts.Get(key)); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs index 258fa8cf..e71a2b9f 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs @@ -43,7 +43,7 @@ public async Task TestDelRange() // check that the operation deleted the timestamps IReadOnlyList res = await ts.RangeAsync(key, from, to); - Assert.Equal(0, res.Count); + Assert.Empty(res); Assert.NotNull(await ts.GetAsync(key)); } } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs index 6030d386..a9c519f6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs @@ -108,8 +108,8 @@ public async void TestIncrByAndIgnoreValues(string endpointId) RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k); Assert.NotNull(info); Assert.True(info.Length > 0); - Assert.NotEqual(j, -1); - Assert.NotEqual(k, -1); + Assert.NotEqual(-1, j); + Assert.NotEqual(-1, k); Assert.Equal(15, (long)info[j + 1]); Assert.Equal(16, (long)info[k + 1]); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs index 109a65ae..7375f15a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs @@ -50,7 +50,7 @@ public void TestSimpleMRange(string endpointId) for (int i = 0; i < results.Count; i++) { Assert.Equal(_keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(tuples, results[i].values); } } @@ -118,9 +118,9 @@ public void TestMRangeFilter(string endpointId) ts.Create(_keys[0], labels: labels); var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeFilter" }); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(_keys[0], results[0].key); - Assert.Equal(0, results[0].labels.Count); + Assert.Empty(results[0].labels); Assert.Equal(tuples, results[0].values); } @@ -144,7 +144,7 @@ public void TestMRangeCount(string endpointId) for (int i = 0; i < results.Count; i++) { Assert.Equal(_keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(tuples.GetRange(0, (int)count), results[i].values); } } @@ -168,7 +168,7 @@ public void TestMRangeAggregation(string endpointId) for (int i = 0; i < results.Count; i++) { Assert.Equal(_keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(tuples, results[i].values); } } @@ -189,7 +189,7 @@ public void TestMRangeAlign(string endpointId) new TimeSeriesTuple(100,1) }; var results = ts.MRange(0, "+", new List { "key=MRangeAlign" }, align: "-", aggregation: TsAggregation.Count, timeBucket: 10, count: 3); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(_keys[0], results[0].key); Assert.Equal(expected, results[0].values); results = ts.MRange(1, 500, new List { "key=MRangeAlign" }, align: "+", aggregation: TsAggregation.Count, timeBucket: 10, count: 1); @@ -270,7 +270,7 @@ public void TestMRangeReduceSum(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Sum)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "sum"), results[0].labels[1]); @@ -295,7 +295,7 @@ public void TestMRangeReduceAvg(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Avg)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "avg"), results[0].labels[1]); @@ -320,7 +320,7 @@ public void TestMRangeReduceRange(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Range)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "range"), results[0].labels[1]); @@ -345,7 +345,7 @@ public void TestMRangeReduceCount(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Count)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "count"), results[0].labels[1]); @@ -370,7 +370,7 @@ public void TestMRangeReduceStdP(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.StdP)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "std.p"), results[0].labels[1]); @@ -395,7 +395,7 @@ public void TestMRangeReduceStdS(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.StdS)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "std.s"), results[0].labels[1]); @@ -420,7 +420,7 @@ public void TestMRangeReduceVarP(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.VarP)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "var.p"), results[0].labels[1]); @@ -445,7 +445,7 @@ public void TestMRangeReduceVarS(string endpointId) var tuples = CreateData(ts, 50); var results = ts.MRange("-", "+", new List { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.VarS)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal("key=MRangeReduce", results[0].key); Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "var.s"), results[0].labels[1]); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs index a1ac13ce..4c5018c1 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs @@ -49,7 +49,7 @@ public async Task TestSimpleMRange(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(tuples, results[i].values); } } @@ -125,9 +125,9 @@ public async Task TestMRangeFilter(string endpointId) await ts.CreateAsync(keys[0], labels: labels); var tuples = await CreateData(ts, keys, 50); var results = await ts.MRangeAsync("-", "+", new List { $"{keys[0]}=value" }); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(keys[0], results[0].key); - Assert.Equal(0, results[0].labels.Count); + Assert.Empty(results[0].labels); Assert.Equal(tuples, results[0].values); } @@ -152,7 +152,7 @@ public async Task TestMRangeCount(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(tuples.GetRange(0, (int)count), results[i].values); } } @@ -177,7 +177,7 @@ public async Task TestMRangeAggregation(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(tuples, results[i].values); } } @@ -199,7 +199,7 @@ public async Task TestMRangeAlign(string endpointId) new TimeSeriesTuple(100,1) }; var results = await ts.MRangeAsync(0, "+", new List { $"{keys[0]}=value" }, align: "-", aggregation: TsAggregation.Count, timeBucket: 10, count: 3); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(keys[0], results[0].key); Assert.Equal(expected, results[0].values); results = await ts.MRangeAsync(0, 500, new List { $"{keys[0]}=value" }, align: "+", aggregation: TsAggregation.Count, timeBucket: 10, count: 1); @@ -291,7 +291,7 @@ public async Task TestMRangeReduce(string endpointId) var tuples = await CreateData(ts, keys, 50); var results = await ts.MRangeAsync("-", "+", new List { $"{keys[0]}=value" }, withLabels: true, groupbyTuple: (keys[0], TsReduce.Sum)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal($"{keys[0]}=value", results[0].key); Assert.Equal(new TimeSeriesLabel(keys[0], "value"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "sum"), results[0].labels[1]); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs index 9491cbb2..39186562 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs @@ -48,7 +48,7 @@ public void TestSimpleMRevRange(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(ReverseData(tuples), results[i].values); } } @@ -116,9 +116,9 @@ public void TestMRevRangeFilter(string endpointId) ts.Create(keys[0], labels: labels); var tuples = CreateData(ts, keys, 50); var results = ts.MRevRange("-", "+", new List { $"{keys[0]}=value" }); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(keys[0], results[0].key); - Assert.Equal(0, results[0].labels.Count); + Assert.Empty(results[0].labels); Assert.Equal(ReverseData(tuples), results[0].values); } @@ -143,7 +143,7 @@ public void TestMRevRangeCount(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(ReverseData(tuples).GetRange(0, (int)count), results[i].values); } } @@ -168,7 +168,7 @@ public void TestMRevRangeAggregation(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(ReverseData(tuples), results[i].values); } } @@ -190,7 +190,7 @@ public void TestMRevRangeAlign(string endpointId) new TimeSeriesTuple(350,1) }; var results = ts.MRevRange(0, "+", new List { $"{keys[0]}=value" }, align: "-", aggregation: TsAggregation.Count, timeBucket: 10, count: 3); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(keys[0], results[0].key); Assert.Equal(expected, results[0].values); results = ts.MRevRange(0, 500, new List { $"{keys[0]}=value" }, align: "+", aggregation: TsAggregation.Count, timeBucket: 10, count: 1); @@ -277,7 +277,7 @@ public void TestMRevRangeReduce(string endpointId) var tuples = CreateData(ts, keys, 50); var results = ts.MRevRange("-", "+", new List { $"{keys[0]}=value" }, withLabels: true, groupbyTuple: (keys[0], TsReduce.Sum)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal($"{keys[0]}=value", results[0].key); Assert.Equal(new TimeSeriesLabel(keys[0], "value"), results[0].labels[0]); Assert.Equal(new TimeSeriesLabel("__reducer__", "sum"), results[0].labels[1]); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs index 3b84c4bd..0ac01910 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs @@ -49,7 +49,7 @@ public async Task TestSimpleMRevRange(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(ReverseData(tuples), results[i].values); } } @@ -116,9 +116,9 @@ public async Task TestMRevRangeFilter(string endpointId) await ts.CreateAsync(keys[0], labels: labels); var tuples = await CreateData(ts, keys, 50); var results = await ts.MRevRangeAsync("-", "+", new List { $"{keys[0]}=value" }); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(keys[0], results[0].key); - Assert.Equal(0, results[0].labels.Count); + Assert.Empty(results[0].labels); Assert.Equal(ReverseData(tuples), results[0].values); } @@ -143,7 +143,7 @@ public async Task TestMRevRangeCount(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(ReverseData(tuples).GetRange(0, (int)count), results[i].values); } } @@ -168,7 +168,7 @@ public async Task TestMRangeAggregation(string endpointId) for (var i = 0; i < results.Count; i++) { Assert.Equal(keys[i], results[i].key); - Assert.Equal(0, results[i].labels.Count); + Assert.Empty(results[i].labels); Assert.Equal(ReverseData(tuples), results[i].values); } } @@ -190,7 +190,7 @@ public async Task TestMRevRangeAlign(string endpointId) new TimeSeriesTuple(350,1) }; var results = await ts.MRevRangeAsync(0, "+", new List { $"{keys[0]}=value" }, align: "-", aggregation: TsAggregation.Count, timeBucket: 10, count: 3); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal(keys[0], results[0].key); Assert.Equal(expected, results[0].values); results = await ts.MRevRangeAsync(0, 500, new List { $"{keys[0]}=value" }, align: "+", aggregation: TsAggregation.Count, timeBucket: 10, count: 1); @@ -282,7 +282,7 @@ public async Task TestMRevRangeReduce(string endpointId) var tuples = await CreateData(ts, keys, 50); var results = await ts.MRevRangeAsync("-", "+", new List { $"{keys[0]}=value" }, withLabels: true, groupbyTuple: (keys[0], TsReduce.Sum)); - Assert.Equal(1, results.Count); + Assert.Single(results); Assert.Equal($"{keys[0]}=value", results[0].key); Assert.Equal(new TimeSeriesLabel(keys[0], "value"), results[0].labels.FirstOrDefault()); Assert.Equal(new TimeSeriesLabel("__reducer__", "sum"), results[0].labels[1]); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs index 6744dc35..8531c6bf 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs @@ -171,7 +171,7 @@ public void TestAlignTimestamp(string endpointId) ts.Add("ts1", 10, 3); ts.Add("ts1", 21, 7); Assert.Equal(2, ts.Range("ts2", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10).Count); - Assert.Equal(1, ts.Range("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10).Count); + Assert.Single(ts.Range("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs index f6f8b47a..b7dc2ca9 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs @@ -175,7 +175,7 @@ public async Task TestAlignTimestampAsync(string endpointId) ts.Add("ts1", 10, 3); ts.Add("ts1", 21, 7); Assert.Equal(2, (await ts.RangeAsync("ts2", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)).Count); - Assert.Equal(1, (await ts.RangeAsync("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)).Count); + Assert.Single((await ts.RangeAsync("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10))); } [Fact] diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs index ea658f4b..5c115812 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs @@ -114,7 +114,7 @@ public void TestAlignTimestamp(string endpointId) ts.Add("ts1", 21, 7); Assert.Equal(2, ts.Range("ts2", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10).Count); - Assert.Equal(1, ts.Range("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10).Count); + Assert.Single(ts.Range("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)); } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs index 3632605d..21b07234 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs @@ -112,7 +112,7 @@ public async Task TestAlignTimestampAsync(string endpointId) await ts.AddAsync("ts1", 21, 7); Assert.Equal(2, (await ts.RangeAsync("ts2", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)).Count); - Assert.Equal(1, (await ts.RangeAsync("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)).Count); + Assert.Single((await ts.RangeAsync("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10))); } } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs index e5d1097e..6a8dd707 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs @@ -39,7 +39,7 @@ public void TestInformationSync() Assert.Equal(1, infoDebug.ChunkCount); Assert.Null(infoDebug.DuplicatePolicy); Assert.Equal(infoDebug.KeySelfName, key); - Assert.Equal(1, infoDebug.Chunks!.Count); + Assert.Single(infoDebug.Chunks!); } [Fact] @@ -67,7 +67,7 @@ public async Task TestInformationAsync() Assert.Equal(1, infoDebug.ChunkCount); Assert.Null(infoDebug.DuplicatePolicy); Assert.Equal(infoDebug.KeySelfName, key); - Assert.Equal(1, infoDebug.Chunks!.Count); + Assert.Single(infoDebug.Chunks!); } } } \ No newline at end of file