Skip to content

Commit 8a17e47

Browse files
authored
Fix formatting issues (#386)
* fix format issues according to xunit 2.9.3 * adding REDIS_VERSION for test runners in IDE
1 parent 27ee1ad commit 8a17e47

25 files changed

+94
-82
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ FodyWeavers.xsd
382382
!.vscode/tasks.json
383383
!.vscode/launch.json
384384
!.vscode/extensions.json
385+
!.vscode/.runsettings
385386
*.code-workspace
386387

387388
# Local History for Visual Studio Code

.vscode/.runsettings

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- File name extension must be .runsettings -->
3+
<RunSettings>
4+
<RunConfiguration>
5+
<EnvironmentVariables>
6+
<!-- List of environment variables we want to set-->
7+
<REDIS_VERSION>7.4.0</REDIS_VERSION>
8+
</EnvironmentVariables>
9+
</RunConfiguration>
10+
</RunSettings>

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info",
33
"dotnet-test-explorer.testProjectPath": "**/*NRedisStack.Tests.csproj",
4-
"dotnet.defaultSolution": "NRedisStack.sln"
4+
"dotnet.defaultSolution": "NRedisStack.sln",
5+
"dotnet.unitTests.runSettingsPath": ".vscode/.runsettings"
56
}

tests/NRedisStack.Tests/Bloom/BloomTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public void TestInfo(string endpointId)
239239
var info = bf.Info(key);
240240

241241
Assert.NotNull(info);
242-
Assert.Equal(info.NumberOfItemsInserted, (long)1);
242+
Assert.Equal((long)1, info.NumberOfItemsInserted);
243243

244244
Assert.Throws<RedisServerException>(() => bf.Info("notExistKey"));
245245
}
@@ -255,7 +255,7 @@ public async Task TestInfoAsync(string endpointId)
255255
var info = await bf.InfoAsync(key);
256256

257257
Assert.NotNull(info);
258-
Assert.Equal(info.NumberOfItemsInserted, (long)1);
258+
Assert.Equal((long)1, info.NumberOfItemsInserted);
259259

260260
await Assert.ThrowsAsync<RedisServerException>(() => bf.InfoAsync("notExistKey"));
261261
}

tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ public void TestInfo(string endpointId)
192192
var info = cf.Info(key);
193193

194194
Assert.NotNull(info);
195-
Assert.Equal(info.BucketSize, (long)2);
196-
Assert.Equal(info.ExpansionRate, (long)1);
197-
Assert.Equal(info.MaxIterations, (long)20);
198-
Assert.Equal(info.NumberOfBuckets, (long)512);
199-
Assert.Equal(info.NumberOfFilters, (long)1);
200-
Assert.Equal(info.NumberOfItemsDeleted, (long)0);
201-
Assert.Equal(info.NumberOfItemsInserted, (long)1);
202-
Assert.Equal(info.Size, (long)1080);
195+
Assert.Equal((long)2, info.BucketSize);
196+
Assert.Equal((long)1, info.ExpansionRate);
197+
Assert.Equal((long)20, info.MaxIterations);
198+
Assert.Equal((long)512, info.NumberOfBuckets);
199+
Assert.Equal((long)1, info.NumberOfFilters);
200+
Assert.Equal((long)0, info.NumberOfItemsDeleted);
201+
Assert.Equal((long)1, info.NumberOfItemsInserted);
202+
Assert.Equal((long)1080, info.Size);
203203

204204
Assert.Throws<RedisServerException>(() => cf.Info("notExistKey"));
205205
}
@@ -215,14 +215,14 @@ public async Task TestInfoAsync(string endpointId)
215215
var info = await cf.InfoAsync(key);
216216

217217
Assert.NotNull(info);
218-
Assert.Equal(info.BucketSize, (long)2);
219-
Assert.Equal(info.ExpansionRate, (long)1);
220-
Assert.Equal(info.MaxIterations, (long)20);
221-
Assert.Equal(info.NumberOfBuckets, (long)512);
222-
Assert.Equal(info.NumberOfFilters, (long)1);
223-
Assert.Equal(info.NumberOfItemsDeleted, (long)0);
224-
Assert.Equal(info.NumberOfItemsInserted, (long)1);
225-
Assert.Equal(info.Size, (long)1080);
218+
Assert.Equal((long)2, info.BucketSize);
219+
Assert.Equal((long)1, info.ExpansionRate);
220+
Assert.Equal((long)20, info.MaxIterations);
221+
Assert.Equal((long)512, info.NumberOfBuckets);
222+
Assert.Equal((long)1, info.NumberOfFilters);
223+
Assert.Equal((long)0, info.NumberOfItemsDeleted);
224+
Assert.Equal((long)1, info.NumberOfItemsInserted);
225+
Assert.Equal((long)1080, info.Size);
226226

227227

228228

tests/NRedisStack.Tests/Examples/ExampleTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public async Task PipelineWithAsync(string endpointId)
225225
selectedLabels: new List<string> { "location" });
226226

227227
// Assert the response
228-
Assert.Equal(1, response.Count);
228+
Assert.Single(response);
229229
Assert.Equal("temp:JLM", response[0].key);
230230
}
231231

tests/NRedisStack.Tests/Json/JsonTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ public void TestMultiPathGet(string endpointId)
990990
}
991991
else
992992
{
993-
Assert.True(false, "$..a was not a json array");
993+
Assert.Fail("$..a was not a json array");
994994
}
995995

996996
Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world");
@@ -1015,7 +1015,7 @@ public async Task TestMultiPathGetAsync(string endpointId)
10151015
}
10161016
else
10171017
{
1018-
Assert.True(false, "$..a was not a json array");
1018+
Assert.Fail("$..a was not a json array");
10191019
}
10201020

10211021
Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world");

tests/NRedisStack.Tests/Search/SearchTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ public void TestLimit(string endpointId)
21702170
var req = new AggregationRequest("*").SortBy("@t1").Limit(1);
21712171
var res = ft.Aggregate("idx", req);
21722172

2173-
Assert.Equal(1, res.GetResults().Count);
2173+
Assert.Single(res.GetResults());
21742174
Assert.Equal("a", res.GetResults()[0]["t1"].ToString());
21752175
}
21762176

@@ -2190,7 +2190,7 @@ public async Task TestLimitAsync(string endpointId)
21902190
var req = new AggregationRequest("*").SortBy("@t1").Limit(1, 1);
21912191
var res = await ft.AggregateAsync("idx", req);
21922192

2193-
Assert.Equal(1, res.GetResults().Count);
2193+
Assert.Single(res.GetResults());
21942194
Assert.Equal("b", res.GetResults()[0]["t1"].ToString());
21952195
}
21962196

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ public void TestAddAndIgnoreValues(string endpointId)
228228
RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k);
229229
Assert.NotNull(info);
230230
Assert.True(info.Length > 0);
231-
Assert.NotEqual(j, -1);
232-
Assert.NotEqual(k, -1);
231+
Assert.NotEqual(-1, j);
232+
Assert.NotEqual(-1, k);
233233
Assert.Equal(15, (long)info[j + 1]);
234234
Assert.Equal(16, (long)info[k + 1]);
235235
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public void TestAlterAndIgnoreValues(string endpointId)
7373
RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k);
7474
Assert.NotNull(info);
7575
Assert.True(info.Length > 0);
76-
Assert.NotEqual(j, -1);
77-
Assert.NotEqual(k, -1);
76+
Assert.NotEqual(-1, j);
77+
Assert.NotEqual(-1, k);
7878
Assert.Equal(13, (long)info[j + 1]);
7979
Assert.Equal(14, (long)info[k + 1]);
8080
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ public void TestCreateAndIgnoreValues(string endpointId)
122122
int j = -1, k = -1;
123123
RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k);
124124

125-
Assert.NotEqual(j, -1);
126-
Assert.NotEqual(k, -1);
125+
Assert.NotEqual(-1, j);
126+
Assert.NotEqual(-1, k);
127127
Assert.Equal(11, (long)info[j + 1]);
128128
Assert.Equal(12, (long)info[k + 1]);
129129
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public async Task TestCreateUncompressed()
7171
}
7272

7373
[Fact]
74-
public async void TestCreatehDuplicatePolicyFirst()
74+
public async Task TestCreatehDuplicatePolicyFirst()
7575
{
7676
var key = CreateKeyName();
7777
var db = GetCleanDatabase();
@@ -80,7 +80,7 @@ public async void TestCreatehDuplicatePolicyFirst()
8080
}
8181

8282
[Fact]
83-
public async void TestCreatehDuplicatePolicyLast()
83+
public async Task TestCreatehDuplicatePolicyLast()
8484
{
8585
var key = CreateKeyName();
8686
var db = GetCleanDatabase();
@@ -89,7 +89,7 @@ public async void TestCreatehDuplicatePolicyLast()
8989
}
9090

9191
[Fact]
92-
public async void TestCreatehDuplicatePolicyMin()
92+
public async Task TestCreatehDuplicatePolicyMin()
9393
{
9494
var key = CreateKeyName();
9595
var db = GetCleanDatabase();
@@ -98,7 +98,7 @@ public async void TestCreatehDuplicatePolicyMin()
9898
}
9999

100100
[Fact]
101-
public async void TestCreatehDuplicatePolicyMax()
101+
public async Task TestCreatehDuplicatePolicyMax()
102102
{
103103
var key = CreateKeyName();
104104
var db = GetCleanDatabase();
@@ -107,7 +107,7 @@ public async void TestCreatehDuplicatePolicyMax()
107107
}
108108

109109
[Fact]
110-
public async void TestCreatehDuplicatePolicySum()
110+
public async Task TestCreatehDuplicatePolicySum()
111111
{
112112
var key = CreateKeyName();
113113
var db = GetCleanDatabase();

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public async void TestIncrDecryByAndIgnoreValues(string endpointId)
109109
RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k);
110110
Assert.NotNull(info);
111111
Assert.True(info.Length > 0);
112-
Assert.NotEqual(j, -1);
113-
Assert.NotEqual(k, -1);
112+
Assert.NotEqual(-1, j);
113+
Assert.NotEqual(-1, k);
114114
Assert.Equal(15, (long)info[j + 1]);
115115
Assert.Equal(16, (long)info[k + 1]);
116116
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void TestDelRange()
4545

4646
// check that the operation deleted the timestamps
4747
IReadOnlyList<TimeSeriesTuple> res = ts.Range(key, from, to);
48-
Assert.Equal(0, res.Count);
48+
Assert.Empty(res);
4949
Assert.NotNull(ts.Get(key));
5050
}
5151
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task TestDelRange()
4343

4444
// check that the operation deleted the timestamps
4545
IReadOnlyList<TimeSeriesTuple> res = await ts.RangeAsync(key, from, to);
46-
Assert.Equal(0, res.Count);
46+
Assert.Empty(res);
4747
Assert.NotNull(await ts.GetAsync(key));
4848
}
4949
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public async void TestIncrByAndIgnoreValues(string endpointId)
108108
RedisResult info = TimeSeriesHelper.getInfo(db, key, out j, out k);
109109
Assert.NotNull(info);
110110
Assert.True(info.Length > 0);
111-
Assert.NotEqual(j, -1);
112-
Assert.NotEqual(k, -1);
111+
Assert.NotEqual(-1, j);
112+
Assert.NotEqual(-1, k);
113113
Assert.Equal(15, (long)info[j + 1]);
114114
Assert.Equal(16, (long)info[k + 1]);
115115
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void TestSimpleMRange(string endpointId)
5050
for (int i = 0; i < results.Count; i++)
5151
{
5252
Assert.Equal(_keys[i], results[i].key);
53-
Assert.Equal(0, results[i].labels.Count);
53+
Assert.Empty(results[i].labels);
5454
Assert.Equal(tuples, results[i].values);
5555
}
5656
}
@@ -118,9 +118,9 @@ public void TestMRangeFilter(string endpointId)
118118
ts.Create(_keys[0], labels: labels);
119119
var tuples = CreateData(ts, 50);
120120
var results = ts.MRange("-", "+", new List<string> { "key=MRangeFilter" });
121-
Assert.Equal(1, results.Count);
121+
Assert.Single(results);
122122
Assert.Equal(_keys[0], results[0].key);
123-
Assert.Equal(0, results[0].labels.Count);
123+
Assert.Empty(results[0].labels);
124124
Assert.Equal(tuples, results[0].values);
125125
}
126126

@@ -144,7 +144,7 @@ public void TestMRangeCount(string endpointId)
144144
for (int i = 0; i < results.Count; i++)
145145
{
146146
Assert.Equal(_keys[i], results[i].key);
147-
Assert.Equal(0, results[i].labels.Count);
147+
Assert.Empty(results[i].labels);
148148
Assert.Equal(tuples.GetRange(0, (int)count), results[i].values);
149149
}
150150
}
@@ -168,7 +168,7 @@ public void TestMRangeAggregation(string endpointId)
168168
for (int i = 0; i < results.Count; i++)
169169
{
170170
Assert.Equal(_keys[i], results[i].key);
171-
Assert.Equal(0, results[i].labels.Count);
171+
Assert.Empty(results[i].labels);
172172
Assert.Equal(tuples, results[i].values);
173173
}
174174
}
@@ -189,7 +189,7 @@ public void TestMRangeAlign(string endpointId)
189189
new TimeSeriesTuple(100,1)
190190
};
191191
var results = ts.MRange(0, "+", new List<string> { "key=MRangeAlign" }, align: "-", aggregation: TsAggregation.Count, timeBucket: 10, count: 3);
192-
Assert.Equal(1, results.Count);
192+
Assert.Single(results);
193193
Assert.Equal(_keys[0], results[0].key);
194194
Assert.Equal(expected, results[0].values);
195195
results = ts.MRange(1, 500, new List<string> { "key=MRangeAlign" }, align: "+", aggregation: TsAggregation.Count, timeBucket: 10, count: 1);
@@ -270,7 +270,7 @@ public void TestMRangeReduceSum(string endpointId)
270270

271271
var tuples = CreateData(ts, 50);
272272
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Sum));
273-
Assert.Equal(1, results.Count);
273+
Assert.Single(results);
274274
Assert.Equal("key=MRangeReduce", results[0].key);
275275
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
276276
Assert.Equal(new TimeSeriesLabel("__reducer__", "sum"), results[0].labels[1]);
@@ -295,7 +295,7 @@ public void TestMRangeReduceAvg(string endpointId)
295295

296296
var tuples = CreateData(ts, 50);
297297
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Avg));
298-
Assert.Equal(1, results.Count);
298+
Assert.Single(results);
299299
Assert.Equal("key=MRangeReduce", results[0].key);
300300
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
301301
Assert.Equal(new TimeSeriesLabel("__reducer__", "avg"), results[0].labels[1]);
@@ -320,7 +320,7 @@ public void TestMRangeReduceRange(string endpointId)
320320

321321
var tuples = CreateData(ts, 50);
322322
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Range));
323-
Assert.Equal(1, results.Count);
323+
Assert.Single(results);
324324
Assert.Equal("key=MRangeReduce", results[0].key);
325325
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
326326
Assert.Equal(new TimeSeriesLabel("__reducer__", "range"), results[0].labels[1]);
@@ -345,7 +345,7 @@ public void TestMRangeReduceCount(string endpointId)
345345

346346
var tuples = CreateData(ts, 50);
347347
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.Count));
348-
Assert.Equal(1, results.Count);
348+
Assert.Single(results);
349349
Assert.Equal("key=MRangeReduce", results[0].key);
350350
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
351351
Assert.Equal(new TimeSeriesLabel("__reducer__", "count"), results[0].labels[1]);
@@ -370,7 +370,7 @@ public void TestMRangeReduceStdP(string endpointId)
370370

371371
var tuples = CreateData(ts, 50);
372372
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.StdP));
373-
Assert.Equal(1, results.Count);
373+
Assert.Single(results);
374374
Assert.Equal("key=MRangeReduce", results[0].key);
375375
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
376376
Assert.Equal(new TimeSeriesLabel("__reducer__", "std.p"), results[0].labels[1]);
@@ -395,7 +395,7 @@ public void TestMRangeReduceStdS(string endpointId)
395395

396396
var tuples = CreateData(ts, 50);
397397
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.StdS));
398-
Assert.Equal(1, results.Count);
398+
Assert.Single(results);
399399
Assert.Equal("key=MRangeReduce", results[0].key);
400400
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
401401
Assert.Equal(new TimeSeriesLabel("__reducer__", "std.s"), results[0].labels[1]);
@@ -420,7 +420,7 @@ public void TestMRangeReduceVarP(string endpointId)
420420

421421
var tuples = CreateData(ts, 50);
422422
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.VarP));
423-
Assert.Equal(1, results.Count);
423+
Assert.Single(results);
424424
Assert.Equal("key=MRangeReduce", results[0].key);
425425
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
426426
Assert.Equal(new TimeSeriesLabel("__reducer__", "var.p"), results[0].labels[1]);
@@ -445,7 +445,7 @@ public void TestMRangeReduceVarS(string endpointId)
445445

446446
var tuples = CreateData(ts, 50);
447447
var results = ts.MRange("-", "+", new List<string> { "key=MRangeReduce" }, withLabels: true, groupbyTuple: ("key", TsReduce.VarS));
448-
Assert.Equal(1, results.Count);
448+
Assert.Single(results);
449449
Assert.Equal("key=MRangeReduce", results[0].key);
450450
Assert.Equal(new TimeSeriesLabel("key", "MRangeReduce"), results[0].labels[0]);
451451
Assert.Equal(new TimeSeriesLabel("__reducer__", "var.s"), results[0].labels[1]);

0 commit comments

Comments
 (0)