This repository was archived by the owner on Dec 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 870
/
Copy pathRedisTemplateTests.cs
47 lines (37 loc) · 1.83 KB
/
RedisTemplateTests.cs
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
using NUnit.Framework;
using ServiceStack.Script;
using ServiceStack.Templates;
namespace ServiceStack.Redis.Tests
{
class RedisTemplateTests
{
[Test]
public void Does_build_connection_string()
{
var context = new ScriptContext
{
ScriptMethods = { new RedisScripts() }
};
context.Container.AddSingleton<IRedisClientsManager>(() => new RedisManagerPool());
context.Init();
Assert.That(context.EvaluateScript("{{ redisToConnectionString: host:7000?db=1 }}"),
Is.EqualTo("host:7000?db=1"));
Assert.That(context.EvaluateScript("{{ { host: 'host' } | redisToConnectionString }}"),
Is.EqualTo("host:6379?db=0"));
Assert.That(context.EvaluateScript("{{ { port: 7000 } | redisToConnectionString }}"),
Is.EqualTo("localhost:7000?db=0"));
Assert.That(context.EvaluateScript("{{ { db: 1 } | redisToConnectionString }}"),
Is.EqualTo("localhost:6379?db=1"));
Assert.That(context.EvaluateScript("{{ { host: 'host', port: 7000, db: 1 } | redisToConnectionString }}"),
Is.EqualTo("host:7000?db=1"));
Assert.That(context.EvaluateScript("{{ { host: 'host', port: 7000, db: 1, password:'secret' } | redisToConnectionString | raw }}"),
Is.EqualTo("host:7000?db=1&password=secret"));
Assert.That(context.EvaluateScript("{{ redisConnectionString }}"),
Is.EqualTo("localhost:6379?db=0"));
Assert.That(context.EvaluateScript("{{ { db: 1 } | redisChangeConnection }}"),
Is.EqualTo("localhost:6379?db=1"));
Assert.That(context.EvaluateScript("{{ redisConnectionString }}"),
Is.EqualTo("localhost:6379?db=1"));
}
}
}