forked from ravendb/ravendb
/
ConnectionStrings.cs
117 lines (104 loc) · 3.58 KB
/
ConnectionStrings.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System.Collections.Generic;
using System.Linq;
using Raven.Client.Document;
using Raven.Client.Embedded;
using Raven.Client.Indexes;
using Xunit;
namespace Raven.Tests
{
public class ConnectionStrings : LocalClientTest
{
[Fact]
public void check_url()
{
using (var store = new DocumentStore())
{
store.ParseConnectionString("Url=http://localhost:8080/;");
Assert.Equal("http://localhost:8080/", store.Url);
Assert.Equal("http://localhost:8080/", store.Identifier);
Assert.NotNull(store.ResourceManagerId);
Assert.NotNull(store.Credentials);
Assert.Null(store.DefaultDatabase);
Assert.True(store.EnlistInDistributedTransactions);
}
}
[Fact]
public void check_illegal_connstrings()
{
using (var store = new DocumentStore())
{
Assert.Throws<System.ArgumentException>(() => store.ParseConnectionString(string.Empty));
}
}
[Fact]
public void check_with_rmid()
{
using (var store = new DocumentStore())
{
store.ParseConnectionString("ResourceManagerId=d5723e19-92ad-4531-adad-8611e6e05c8a;");
Assert.Null(store.Url);
Assert.Null(store.Identifier);
Assert.Equal("d5723e19-92ad-4531-adad-8611e6e05c8a", store.ResourceManagerId.ToString());
Assert.NotNull(store.Credentials);
Assert.Null(store.DefaultDatabase);
Assert.True(store.EnlistInDistributedTransactions);
}
}
[Fact]
public void check_url_and_rmid()
{
using (var store = new DocumentStore())
{
store.ParseConnectionString("Url=http://localhost:8080/;ResourceManagerId=d5723e19-92ad-4531-adad-8611e6e05c8a;");
Assert.Equal("http://localhost:8080/", store.Url);
Assert.Equal("http://localhost:8080/", store.Identifier);
Assert.Equal("d5723e19-92ad-4531-adad-8611e6e05c8a", store.ResourceManagerId.ToString());
Assert.NotNull(store.Credentials);
Assert.Null(store.DefaultDatabase);
Assert.True(store.EnlistInDistributedTransactions);
}
}
[Fact]
public void check_defaultdb()
{
using (var store = new DocumentStore())
{
store.ParseConnectionString("DefaultDatabase=DevMachine;");
Assert.Null(store.Url);
Assert.Null(store.Identifier);
Assert.NotNull(store.ResourceManagerId);
Assert.NotNull(store.Credentials);
Assert.Equal("DevMachine", store.DefaultDatabase);
Assert.True(store.EnlistInDistributedTransactions);
}
}
[Fact]
public void check_url_and_defaultdb()
{
using (var store = new DocumentStore())
{
store.ParseConnectionString("Url=http://localhost:8080/;DefaultDatabase=DevMachine;");
Assert.Equal("http://localhost:8080/", store.Url);
Assert.Equal("http://localhost:8080/ (DB: DevMachine)", store.Identifier);
Assert.NotNull(store.ResourceManagerId);
Assert.NotNull(store.Credentials);
Assert.Equal("DevMachine", store.DefaultDatabase);
Assert.True(store.EnlistInDistributedTransactions);
}
}
public void can_work_with_default_db()
{
using (var store = new DocumentStore())
{
store.ParseConnectionString("Url=http://localhost:8080/;DefaultDatabase=DevMachine;ResourceManagerId=d5723e19-92ad-4531-adad-8611e6e05c8a;");
Assert.Equal("http://localhost:8080/", store.Url);
Assert.Equal("http://localhost:8080/ (DB: DevMachine)", store.Identifier);
Assert.Equal("d5723e19-92ad-4531-adad-8611e6e05c8a", store.ResourceManagerId.ToString());
Assert.NotNull(store.Credentials);
Assert.Equal("DevMachine", store.DefaultDatabase);
Assert.True(store.EnlistInDistributedTransactions);
}
}
}
}