StackExchange.Redis 为 windows 环境提供了测试套件,截至本文发布前,作者尚未正式发布跨平台的套件信息。
StackExchange.Redis 提供的单元和继承测试很简单,有 2 个主要步骤:
-
开启服务器
-
运行测试
1 2 3 4 5
| { "RunLongRunning": true, "MasterServer": "192.168.10.5", "MasterPort": 2333 }
|
你可以从 github 中获取 json 配置:配置文件路径见此
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| public class Config { public bool UseSharedConnection { get; set; } = true; public bool RunLongRunning { get; set; } public bool LogToConsole { get; set; }
public string MasterServer { get; set; } = "127.0.0.1"; public int MasterPort { get; set; } = 6379; public string MasterServerAndPort => MasterServer + ":" + MasterPort.ToString();
public string SlaveServer { get; set; } = "127.0.0.1"; public int SlavePort { get; set; } = 6380; public string SlaveServerAndPort => SlaveServer + ":" + SlavePort.ToString();
public string SecureServer { get; set; } = "127.0.0.1"; public int SecurePort { get; set; } = 6381; public string SecurePassword { get; set; } = "changeme"; public string SecureServerAndPort => SecureServer + ":" + SecurePort.ToString();
public string FailoverMasterServer { get; set; } = "127.0.0.1"; public int FailoverMasterPort { get; set; } = 6382; public string FailoverMasterServerAndPort => FailoverMasterServer + ":" + FailoverMasterPort.ToString();
public string FailoverSlaveServer { get; set; } = "127.0.0.1"; public int FailoverSlavePort { get; set; } = 6383; public string FailoverSlaveServerAndPort => FailoverSlaveServer + ":" + FailoverSlavePort.ToString();
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 int RemotePort { get; set; } = 6379; public string RemoteServerAndPort => RemoteServer + ":" + RemotePort.ToString();
public string SentinelServer { get; set; } = "127.0.0.1"; public int SentinelPort { get; set; } = 26379; public string SentinelSeviceName { get; set; } = "mymaster";
public string ClusterServer { get; set; } = "127.0.0.1"; public int ClusterStartPort { get; set; } = 7000; public int ClusterServerCount { get; set; } = 6;
public string SslServer { get; set; } public int SslPort { get; set; }
public string RedisLabsSslServer { get; set; } public int RedisLabsSslPort { get; set; } = 6379; public string RedisLabsPfxPath { get; set; }
public string AzureCacheServer { get; set; } public string AzureCachePassword { get; set; }
public string SSDBServer { get; set; } public int SSDBPort { get; set; } = 8888; }
|
在 windows 下测试
默认情况下,测试过程会作为构建的一部分,你可以在 repository 的根目录运行以下命令:
1
| .\build.cmd -BuildNumber local
|
也可以使用更多其他选项:
1 2 3 4
| dotnet build .\RedisConfigs\start-all.cmd cd StackExchange.Redis.Tests dotnet xunit
|