Skip to content

Commit

Permalink
Use redisFixture in all tests (#244)
Browse files Browse the repository at this point in the history
* use redisFixture in all tests

* fix HashExample

* make constractors public

* return Doc to how it was before
  • Loading branch information
shacharPash authored Feb 13, 2024
1 parent 980a77c commit 9a607e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
24 changes: 8 additions & 16 deletions tests/NRedisStack.Tests/Core Commands/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public CoreTests(RedisFixture redisFixture) : base(redisFixture) { }
[SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.1.242")]
public void TestSimpleSetInfo()
{
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");

db.ClientSetInfo(SetInfoAttr.LibraryName, "TestLibraryName");
Expand All @@ -32,8 +31,7 @@ public void TestSimpleSetInfo()
[SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.1.242")]
public async Task TestSimpleSetInfoAsync()
{
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");

await db.ClientSetInfoAsync(SetInfoAttr.LibraryName, "TestLibraryName");
Expand All @@ -47,8 +45,7 @@ public async Task TestSimpleSetInfoAsync()
public void TestSetInfoDefaultValue()
{
ResetInfoDefaults(); // demonstrate first connection
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");

db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
Expand All @@ -61,8 +58,7 @@ public void TestSetInfoDefaultValue()
public async Task TestSetInfoDefaultValueAsync()
{
ResetInfoDefaults(); // demonstrate first connection
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");

await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
Expand All @@ -75,8 +71,7 @@ public async Task TestSetInfoDefaultValueAsync()
public void TestSetInfoWithValue()
{
ResetInfoDefaults(); // demonstrate first connection
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase("MyLibraryName;v1.0.0");
var db = redisFixture.Redis.GetDatabase("MyLibraryName;v1.0.0");
db.Execute("FLUSHALL");

db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
Expand All @@ -89,8 +84,7 @@ public void TestSetInfoWithValue()
public async Task TestSetInfoWithValueAsync()
{
ResetInfoDefaults(); // demonstrate first connection
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase("MyLibraryName;v1.0.0");
var db = redisFixture.Redis.GetDatabase("MyLibraryName;v1.0.0");
db.Execute("FLUSHALL");

await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version.
Expand All @@ -103,8 +97,7 @@ public async Task TestSetInfoWithValueAsync()
public void TestSetInfoNull()
{
ResetInfoDefaults(); // demonstrate first connection
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase(null);
var db = redisFixture.Redis.GetDatabase(null);

db.Execute("FLUSHALL");
var infoBefore = db.Execute("CLIENT", "INFO").ToString();
Expand All @@ -127,8 +120,7 @@ public void TestSetInfoNull()
public async Task TestSetInfoNullAsync()
{
ResetInfoDefaults(); // demonstrate first connection
var redis = ConnectionMultiplexer.Connect("localhost");
var db = redis.GetDatabase(null);
var db = redisFixture.Redis.GetDatabase(null);

db.Execute("FLUSHALL");
var infoBefore = (await db.ExecuteAsync("CLIENT", "INFO")).ToString();
Expand Down
3 changes: 1 addition & 2 deletions tests/NRedisStack.Tests/Search/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2745,8 +2745,7 @@ public void TestProfileCommandBuilder()
[SkipIfRedis(Is.OSSCluster)]
public void Issue175()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379");
IDatabase db = redis.GetDatabase();
IDatabase db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");

SearchCommands ft = db.FT();
Expand Down

0 comments on commit 9a607e0

Please sign in to comment.