Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify test host and port #117

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions tests/NRedisStack.Tests/Examples/ExamplesTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Text;
using Moq;
using NRedisStack.DataTypes;
using NRedisStack.RedisStackCommands;
Expand Down Expand Up @@ -26,10 +25,11 @@ public void Dispose()
public void HSETandSearch()
{
// Connect to the Redis server
var redis = ConnectionMultiplexer.Connect("localhost");
// var redis = ConnectionMultiplexer.Connect("localhost");

// Get a reference to the database and for search commands:
var db = redis.GetDatabase();
// var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
var ft = db.FT();

Expand Down Expand Up @@ -77,8 +77,9 @@ public void HSETandSearch()
public async Task AsyncExample()
{
// Connect to the Redis server
var redis = await ConnectionMultiplexer.ConnectAsync("localhost");
var db = redis.GetDatabase();
// var redis = await ConnectionMultiplexer.ConnectAsync("localhost");
// var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
var json = db.JSON();

Expand Down Expand Up @@ -169,10 +170,11 @@ public async Task JsonWithSearchPipeline()
public async Task PipelineWithAsync()
{
// Connect to the Redis server
var redis = ConnectionMultiplexer.Connect("localhost");
// var redis = ConnectionMultiplexer.Connect("localhost");

// Get a reference to the database
var db = redis.GetDatabase();
// var db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
// Setup pipeline connection

Expand Down Expand Up @@ -226,10 +228,12 @@ public async Task PipelineWithAsync()
public async Task TransactionExample()
{
// Connect to the Redis server
var redis = ConnectionMultiplexer.Connect("localhost");
// var redis = ConnectionMultiplexer.Connect("localhost");

// Get a reference to the database
var db = redis.GetDatabase();
// var db = redis.GetDatabase();

var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");

// Setup transaction with IDatabase
Expand Down Expand Up @@ -267,8 +271,10 @@ public async Task TransactionExample()
[Fact]
public void TestJsonConvert()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
// ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
// IDatabase db = redis.GetDatabase();

var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
ISearchCommands ft = db.FT();
IJsonCommands json = db.JSON();
Expand All @@ -289,8 +295,9 @@ public void TestJsonConvert()
[Fact]
public void BasicJsonExamplesTest()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
// ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
// IDatabase db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
IJsonCommands json = db.JSON();

Expand Down Expand Up @@ -543,8 +550,9 @@ public void BasicJsonExamplesTest()
[Fact]
public void AdvancedJsonExamplesTest()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
// ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
// IDatabase db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
IJsonCommands json = db.JSON();

Expand Down Expand Up @@ -676,8 +684,9 @@ public void AdvancedJsonExamplesTest()
[Fact]
public void BasicQueryOperationsTest()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
// ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
// IDatabase db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
IJsonCommands json = db.JSON();
ISearchCommands ft = db.FT();
Expand Down Expand Up @@ -835,8 +844,9 @@ public void BasicQueryOperationsTest()
[Fact]
public void AdvancedQueryOperationsTest()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
// ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
// IDatabase db = redis.GetDatabase();
var db = redisFixture.Redis.GetDatabase();
db.Execute("FLUSHALL");
IJsonCommands json = db.JSON();
ISearchCommands ft = db.FT();
Expand Down
23 changes: 0 additions & 23 deletions tests/NRedisStack.Tests/Graph/GraphTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1923,29 +1923,6 @@ public void TestParseInfinity()
Assert.Equal(double.PositiveInfinity, r.Values[0]);
}

[Fact]
public async Task TestModulePrefixs1Async()
{
{
var conn = ConnectionMultiplexer.Connect("localhost");
IDatabase db = conn.GetDatabase();

var graph = db.GRAPH();
// ...
conn.Dispose();
}

{
var conn = ConnectionMultiplexer.Connect("localhost");
IDatabase db = conn.GetDatabase();

var graph = db.GRAPH();
// ...
conn.Dispose();
}

}

[Fact]
public void TestEqualsAndToString()
{
Expand Down
6 changes: 5 additions & 1 deletion tests/NRedisStack.Tests/RedisFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ namespace NRedisStack.Tests
{
public class RedisFixture : IDisposable
{
public RedisFixture() => Redis = ConnectionMultiplexer.Connect("localhost");


// Set the enviroment variable to specify your own alternet host and port:
string redis = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379";
public RedisFixture() => Redis = ConnectionMultiplexer.Connect($"{redis}");

public void Dispose()
{
Expand Down