@@ -18,10 +18,9 @@ public class ConnectionManagerFixture
18
18
[ SetUp ]
19
19
public void SetUp ( )
20
20
{
21
- var stream = Substitute . For < IMessageExchangeStream > ( ) ;
22
- connection = new SecureConnection ( Substitute . For < IDisposable > ( ) , Stream . Null , new MessageExchangeProtocol ( stream ) ) ;
21
+ connection = new SecureConnection ( Substitute . For < IDisposable > ( ) , Stream . Null , GetProtocol , Substitute . For < ILog > ( ) ) ;
23
22
connectionFactory = Substitute . For < IConnectionFactory > ( ) ;
24
- connectionFactory . EstablishNewConnection ( Arg . Any < ServiceEndPoint > ( ) , Arg . Any < ILog > ( ) ) . Returns ( connection ) ;
23
+ connectionFactory . EstablishNewConnection ( GetProtocol , Arg . Any < ServiceEndPoint > ( ) , Arg . Any < ILog > ( ) ) . Returns ( connection ) ;
25
24
}
26
25
27
26
[ Test ]
@@ -31,8 +30,8 @@ public void DisposedConnectionsAreRemovedFromActive_WhenMultipleConnectionsAreAc
31
30
var connectionManager = new ConnectionManager ( ) ;
32
31
33
32
//do it twice because this bug only triggers on multiple enumeration, having 1 in the collection doesn't trigger the bug
34
- connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
35
- connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
33
+ connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
34
+ connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
36
35
37
36
connectionManager . Disconnect ( serviceEndpoint , null ) ;
38
37
connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . BeNullOrEmpty ( ) ;
@@ -44,7 +43,7 @@ public void ReleasedConnectionsAreNotActive()
44
43
var serviceEndpoint = new ServiceEndPoint ( "https://localhost:42" , Certificates . TentacleListeningPublicThumbprint ) ;
45
44
var connectionManager = new ConnectionManager ( ) ;
46
45
47
- var activeConnection = connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
46
+ var activeConnection = connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
48
47
connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . OnlyContain ( c => c == activeConnection ) ;
49
48
50
49
connectionManager . ReleaseConnection ( serviceEndpoint , activeConnection ) ;
@@ -57,7 +56,7 @@ public void DisposedConnectionsAreRemovedFromActive()
57
56
var serviceEndpoint = new ServiceEndPoint ( "https://localhost:42" , Certificates . TentacleListeningPublicThumbprint ) ;
58
57
var connectionManager = new ConnectionManager ( ) ;
59
58
60
- var activeConnection = connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
59
+ var activeConnection = connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
61
60
connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . OnlyContain ( c => c == activeConnection ) ;
62
61
63
62
activeConnection . Dispose ( ) ;
@@ -70,11 +69,16 @@ public void DisconnectDisposesActiveConnections()
70
69
var serviceEndpoint = new ServiceEndPoint ( "https://localhost:42" , Certificates . TentacleListeningPublicThumbprint ) ;
71
70
var connectionManager = new ConnectionManager ( ) ;
72
71
73
- var activeConnection = connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
72
+ var activeConnection = connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
74
73
connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . OnlyContain ( c => c == activeConnection ) ;
75
74
76
75
connectionManager . Disconnect ( serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
77
76
connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . BeNullOrEmpty ( ) ;
78
77
}
78
+
79
+ public MessageExchangeProtocol GetProtocol ( Stream stream , ILog log )
80
+ {
81
+ return new MessageExchangeProtocol ( new MessageExchangeStream ( stream , new Type [ ] { } , log ) , log ) ;
82
+ }
79
83
}
80
84
}
0 commit comments