Commit dba66e70 authored by Nick Craver's avatar Nick Craver

Tests to validate #686

This adds IPv4 parsing and connect testing, verified that the fix in #686 will work.
parent e069adf0
using System.Net.Sockets;
using Xunit;
using Xunit.Abstractions;
namespace StackExchange.Redis.Tests
{
public class ConnectByIP : TestBase
{
public ConnectByIP(ITestOutputHelper output) : base (output) { }
[Fact]
public void ParseEndpoints()
{
var eps = new EndPointCollection
{
{ "127.0.0.1", 1000 },
{ "::1", 1001 }
};
Assert.Equal(AddressFamily.InterNetwork, eps[0].AddressFamily);
Assert.Equal(AddressFamily.InterNetworkV6, eps[1].AddressFamily);
Assert.Equal("127.0.0.1:1000", eps[0].ToString());
Assert.Equal("[::1]:1001", eps[1].ToString());
}
[Fact]
public void IPv4Connection()
{
var config = new ConfigurationOptions
{
EndPoints = { { TestConfig.Current.IPv4Server, TestConfig.Current.IPv4Port } }
};
using (var conn = ConnectionMultiplexer.Connect(config))
{
var server = conn.GetServer(config.EndPoints[0]);
Assert.Equal(AddressFamily.InterNetwork, server.EndPoint.AddressFamily);
server.Ping();
}
}
[Fact]
public void IPv6Connection()
{
var config = new ConfigurationOptions
{
EndPoints = { { TestConfig.Current.IPv6Server, TestConfig.Current.IPv6Port } }
};
using (var conn = ConnectionMultiplexer.Connect(config))
{
var server = conn.GetServer(config.EndPoints[0]);
Assert.Equal(AddressFamily.InterNetworkV6, server.EndPoint.AddressFamily);
server.Ping();
}
}
}
}
...@@ -50,6 +50,11 @@ public class Config ...@@ -50,6 +50,11 @@ public class Config
public int SecurePort { get; set; } = 6381; public int SecurePort { get; set; } = 6381;
public string SecurePassword { get; set; } = "changeme"; public string SecurePassword { get; set; } = "changeme";
public string IPv4Server { get; set; } = "127.0.0.1";
public int IPv4Port { get; set; } = 6379;
public string IPv6Server { get; set; } = "::1";
public int IPv6Port { get; set; } = 6379;
public string RemoteServer { get; set; } = "127.0.0.1"; public string RemoteServer { get; set; } = "127.0.0.1";
public int RemotePort { get; set; } = 6379; public int RemotePort { get; set; } = 6379;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment