Skip to content

Commit

Permalink
Fix formatting issues (#386)
Browse files Browse the repository at this point in the history
* fix format issues according to xunit 2.9.3

* adding REDIS_VERSION for test runners in IDE
  • Loading branch information
atakavci authored Jan 29, 2025
1 parent 27ee1ad commit 8a17e47
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 82 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions .vscode/.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<!-- List of environment variables we want to set-->
<REDIS_VERSION>7.4.0</REDIS_VERSION>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/Bloom/BloomTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RedisServerException>(() => bf.Info("notExistKey"));
}
Expand All @@ -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<RedisServerException>(() => bf.InfoAsync("notExistKey"));
}
Expand Down
32 changes: 16 additions & 16 deletions tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RedisServerException>(() => cf.Info("notExistKey"));
}
Expand All @@ -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);



Expand Down
2 changes: 1 addition & 1 deletion tests/NRedisStack.Tests/Examples/ExampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public async Task PipelineWithAsync(string endpointId)
selectedLabels: new List<string> { "location" });

// Assert the response
Assert.Equal(1, response.Count);
Assert.Single(response);
Assert.Equal("temp:JLM", response[0].key);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/Json/JsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -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());
}

Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task TestCreateUncompressed()
}

[Fact]
public async void TestCreatehDuplicatePolicyFirst()
public async Task TestCreatehDuplicatePolicyFirst()
{
var key = CreateKeyName();
var db = GetCleanDatabase();
Expand All @@ -80,7 +80,7 @@ public async void TestCreatehDuplicatePolicyFirst()
}

[Fact]
public async void TestCreatehDuplicatePolicyLast()
public async Task TestCreatehDuplicatePolicyLast()
{
var key = CreateKeyName();
var db = GetCleanDatabase();
Expand All @@ -89,7 +89,7 @@ public async void TestCreatehDuplicatePolicyLast()
}

[Fact]
public async void TestCreatehDuplicatePolicyMin()
public async Task TestCreatehDuplicatePolicyMin()
{
var key = CreateKeyName();
var db = GetCleanDatabase();
Expand All @@ -98,7 +98,7 @@ public async void TestCreatehDuplicatePolicyMin()
}

[Fact]
public async void TestCreatehDuplicatePolicyMax()
public async Task TestCreatehDuplicatePolicyMax()
{
var key = CreateKeyName();
var db = GetCleanDatabase();
Expand All @@ -107,7 +107,7 @@ public async void TestCreatehDuplicatePolicyMax()
}

[Fact]
public async void TestCreatehDuplicatePolicySum()
public async Task TestCreatehDuplicatePolicySum()
{
var key = CreateKeyName();
var db = GetCleanDatabase();
Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void TestDelRange()

// check that the operation deleted the timestamps
IReadOnlyList<TimeSeriesTuple> res = ts.Range(key, from, to);
Assert.Equal(0, res.Count);
Assert.Empty(res);
Assert.NotNull(ts.Get(key));
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task TestDelRange()

// check that the operation deleted the timestamps
IReadOnlyList<TimeSeriesTuple> res = await ts.RangeAsync(key, from, to);
Assert.Equal(0, res.Count);
Assert.Empty(res);
Assert.NotNull(await ts.GetAsync(key));
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
28 changes: 14 additions & 14 deletions tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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<string> { "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);
}

Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -189,7 +189,7 @@ public void TestMRangeAlign(string endpointId)
new TimeSeriesTuple(100,1)
};
var results = ts.MRange(0, "+", new List<string> { "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<string> { "key=MRangeAlign" }, align: "+", aggregation: TsAggregation.Count, timeBucket: 10, count: 1);
Expand Down Expand Up @@ -270,7 +270,7 @@ public void TestMRangeReduceSum(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -295,7 +295,7 @@ public void TestMRangeReduceAvg(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -320,7 +320,7 @@ public void TestMRangeReduceRange(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -345,7 +345,7 @@ public void TestMRangeReduceCount(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -370,7 +370,7 @@ public void TestMRangeReduceStdP(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -395,7 +395,7 @@ public void TestMRangeReduceStdS(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -420,7 +420,7 @@ public void TestMRangeReduceVarP(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand All @@ -445,7 +445,7 @@ public void TestMRangeReduceVarS(string endpointId)

var tuples = CreateData(ts, 50);
var results = ts.MRange("-", "+", new List<string> { "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]);
Expand Down
Loading

0 comments on commit 8a17e47

Please sign in to comment.