File tree Expand file tree Collapse file tree 3 files changed +9
-84
lines changed
RabbitMQ.Client/src/client/impl Expand file tree Collapse file tree 3 files changed +9
-84
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Linq ;
3
4
using System . Net . Sockets ;
4
5
using System . Net ;
6
+ using System . Text ;
5
7
using System . Threading . Tasks ;
6
-
7
8
namespace RabbitMQ . Client
8
9
{
10
+
11
+
9
12
/// <summary>
10
- /// Simple wrapper around TcpClient.
13
+ /// Simple wrapper around TcpClient.
11
14
/// </summary>
12
15
public class TcpClientAdapter : ITcpClient
13
16
{
@@ -17,18 +20,14 @@ public TcpClientAdapter(Socket socket)
17
20
{
18
21
if ( socket == null )
19
22
throw new InvalidOperationException ( "socket must not be null" ) ;
20
-
23
+
21
24
this . sock = socket ;
22
25
}
23
26
24
27
public virtual async Task ConnectAsync ( string host , int port )
25
28
{
26
29
var adds = await Dns . GetHostAddressesAsync ( host ) . ConfigureAwait ( false ) ;
27
- var ep = adds . FirstOrDefault ( a => a . AddressFamily == sock . AddressFamily ) ;
28
- if ( ep == default ( IPAddress ) )
29
- {
30
- throw new ArgumentException ( "No ip address could be resolved for " + host ) ;
31
- }
30
+ var ep = adds . First ( ) ;
32
31
#if CORECLR
33
32
await sock . ConnectAsync ( ep , port ) ;
34
33
#else
@@ -72,4 +71,4 @@ public virtual int ReceiveTimeout
72
71
}
73
72
}
74
73
}
75
- }
74
+ }
Original file line number Diff line number Diff line change 39
39
//---------------------------------------------------------------------------
40
40
41
41
using System ;
42
- using System . Collections . Generic ;
43
42
using NUnit . Framework ;
44
43
using RabbitMQ . Client . Exceptions ;
45
44
@@ -108,7 +107,7 @@ public void TestCreateConnectionWithClientProvidedNameUsesName()
108
107
Assert . AreEqual ( "some_name" , conn . ClientProperties [ "connection_name" ] ) ;
109
108
}
110
109
}
111
-
110
+
112
111
[ Test ]
113
112
public void TestCreateConnectionWithClientProvidedNameAndAutorecoveryUsesName ( )
114
113
{
@@ -187,14 +186,5 @@ public void TestCreateConnectionUsesInvalidAmqpTcpEndpoint()
187
186
using ( var conn = cf . CreateConnection ( new System . Collections . Generic . List < AmqpTcpEndpoint > { ep } ) ) { }
188
187
} , Throws . TypeOf < BrokerUnreachableException > ( ) ) ;
189
188
}
190
-
191
- [ Test ]
192
- public void TestCreateConnectioUsesValidEndpointWhenMultipleSupplied ( )
193
- {
194
- var cf = new ConnectionFactory ( ) ;
195
- var invalidEp = new AmqpTcpEndpoint ( "not_localhost" ) ;
196
- var ep = new AmqpTcpEndpoint ( "localhost" ) ;
197
- using ( var conn = cf . CreateConnection ( new List < AmqpTcpEndpoint > { invalidEp , ep } ) ) { } ;
198
- }
199
189
}
200
190
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments