@@ -22,9 +22,9 @@ public class SplitPacketTest : IDisposable
22
22
public SplitPacketTest ( )
23
23
{
24
24
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder ( DataTestUtility . TCPConnectionString ) ;
25
- GetTcpInfoFromDataSource ( builder . DataSource , out string actualHost , out int actualPort ) ;
25
+ DataSourceBuilder dataSourceBuilder = new DataSourceBuilder ( builder . DataSource ) ;
26
26
27
- Task . Factory . StartNew ( ( ) => { SetupProxy ( actualHost , actualPort , _cts . Token ) ; } ) ;
27
+ Task . Factory . StartNew ( ( ) => { SetupProxy ( dataSourceBuilder . ServerName , dataSourceBuilder . Port ?? 1433 , _cts . Token ) ; } ) ;
28
28
29
29
for ( int i = 0 ; i < 10 && _port == - 1 ; i ++ )
30
30
{
@@ -159,25 +159,6 @@ private void ForwardToClient(TcpClient ourClient, TcpClient sqlClient, Cancellat
159
159
}
160
160
}
161
161
162
- private static void GetTcpInfoFromDataSource ( string dataSource , out string hostName , out int port )
163
- {
164
- string [ ] dataSourceParts = dataSource . Split ( ',' ) ;
165
- if ( dataSourceParts . Length == 1 )
166
- {
167
- hostName = dataSourceParts [ 0 ] . Replace ( "tcp:" , "" ) ;
168
- port = 1433 ;
169
- }
170
- else if ( dataSourceParts . Length == 2 )
171
- {
172
- hostName = dataSourceParts [ 0 ] . Replace ( "tcp:" , "" ) ;
173
- port = int . Parse ( dataSourceParts [ 1 ] ) ;
174
- }
175
- else
176
- {
177
- throw new InvalidOperationException ( "TCP Connection String not in correct format!" ) ;
178
- }
179
- }
180
-
181
162
public void Dispose ( )
182
163
{
183
164
Dispose ( true ) ;
@@ -190,6 +171,7 @@ protected virtual void Dispose(bool disposing)
190
171
{
191
172
_cts . Cancel ( ) ;
192
173
_cts . Dispose ( ) ;
174
+ _listener ? . Server . Dispose ( ) ;
193
175
#if NETFRAMEWORK
194
176
_listener ? . Stop ( ) ;
195
177
#else
0 commit comments