1
- using Elasticsearch . Net ;
1
+ using System . Runtime . Remoting . Channels ;
2
+ using Elasticsearch . Net ;
2
3
using Elasticsearch . Net . Connection ;
3
4
using NUnit . Framework ;
4
5
using System ;
@@ -8,7 +9,7 @@ namespace Nest.Tests.Unit.Domain.Connection
8
9
{
9
10
using System . Net ;
10
11
11
- public class TestConnection : HttpConnection
12
+ public class TestConnection : InMemoryConnection
12
13
{
13
14
public TestConnection ( IConnectionSettingsValues settings )
14
15
: base ( settings ) { }
@@ -29,13 +30,11 @@ public void CanCreateConnectionWithCustomQueryStringParameters()
29
30
var uri = new Uri ( "http://localhost" ) ;
30
31
var query = new NameValueCollection { { "authToken" , "ABCDEFGHIJK" } } ;
31
32
var connectionSettings = new ConnectionSettings ( uri , "index" ) . SetGlobalQueryStringParameters ( query ) ;
32
- var connection = new TestConnection ( connectionSettings ) ;
33
-
34
- // Act
35
- var req = connection . GetConnection ( "" , "GET" ) ;
33
+ var client = new ElasticClient ( connectionSettings , new TestConnection ( connectionSettings ) ) ;
34
+ var result = client . RootNodeInfo ( ) ;
36
35
37
36
// Assert
38
- Assert . AreEqual ( req . Address . ToString ( ) , "http://localhost/?authToken=ABCDEFGHIJK" ) ;
37
+ Assert . AreEqual ( result . ConnectionStatus . RequestUrl , "http://localhost/?authToken=ABCDEFGHIJK" ) ;
39
38
}
40
39
41
40
[ Test ]
@@ -45,13 +44,11 @@ public void CanCreateConnectionWithPathAndCustomQueryStringParameters()
45
44
var uri = new Uri ( "http://localhost:9000" ) ;
46
45
var query = new NameValueCollection { { "authToken" , "ABCDEFGHIJK" } } ;
47
46
var connectionSettings = new ConnectionSettings ( uri , "index" ) . SetGlobalQueryStringParameters ( query ) ;
48
- var connection = new TestConnection ( connectionSettings ) ;
49
-
50
- // Act
51
- var req = connection . GetConnection ( "index/" , "GET" ) ;
47
+ var client = new ElasticClient ( connectionSettings , new TestConnection ( connectionSettings ) ) ;
48
+ var result = client . IndexExists ( ie=> ie . Index ( "index" ) ) ;
52
49
53
50
// Assert
54
- Assert . AreEqual ( req . Address . ToString ( ) , "http://localhost:9000/index/ ?authToken=ABCDEFGHIJK" ) ;
51
+ Assert . AreEqual ( result . ConnectionStatus . RequestUrl , "http://localhost:9000/index?authToken=ABCDEFGHIJK" ) ;
55
52
}
56
53
57
54
0 commit comments