@@ -18,10 +18,9 @@ public class ConnectionManagerFixture
1818 [ SetUp ]
1919 public void SetUp ( )
2020 {
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 > ( ) ) ;
2322 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 ) ;
2524 }
2625
2726 [ Test ]
@@ -31,8 +30,8 @@ public void DisposedConnectionsAreRemovedFromActive_WhenMultipleConnectionsAreAc
3130 var connectionManager = new ConnectionManager ( ) ;
3231
3332 //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 ( ) ) ) ;
3635
3736 connectionManager . Disconnect ( serviceEndpoint , null ) ;
3837 connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . BeNullOrEmpty ( ) ;
@@ -44,7 +43,7 @@ public void ReleasedConnectionsAreNotActive()
4443 var serviceEndpoint = new ServiceEndPoint ( "https://localhost:42" , Certificates . TentacleListeningPublicThumbprint ) ;
4544 var connectionManager = new ConnectionManager ( ) ;
4645
47- var activeConnection = connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
46+ var activeConnection = connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
4847 connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . OnlyContain ( c => c == activeConnection ) ;
4948
5049 connectionManager . ReleaseConnection ( serviceEndpoint , activeConnection ) ;
@@ -57,7 +56,7 @@ public void DisposedConnectionsAreRemovedFromActive()
5756 var serviceEndpoint = new ServiceEndPoint ( "https://localhost:42" , Certificates . TentacleListeningPublicThumbprint ) ;
5857 var connectionManager = new ConnectionManager ( ) ;
5958
60- var activeConnection = connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
59+ var activeConnection = connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
6160 connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . OnlyContain ( c => c == activeConnection ) ;
6261
6362 activeConnection . Dispose ( ) ;
@@ -70,11 +69,16 @@ public void DisconnectDisposesActiveConnections()
7069 var serviceEndpoint = new ServiceEndPoint ( "https://localhost:42" , Certificates . TentacleListeningPublicThumbprint ) ;
7170 var connectionManager = new ConnectionManager ( ) ;
7271
73- var activeConnection = connectionManager . AcquireConnection ( connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
72+ var activeConnection = connectionManager . AcquireConnection ( GetProtocol , connectionFactory , serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
7473 connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . OnlyContain ( c => c == activeConnection ) ;
7574
7675 connectionManager . Disconnect ( serviceEndpoint , new InMemoryConnectionLog ( serviceEndpoint . ToString ( ) ) ) ;
7776 connectionManager . GetActiveConnections ( serviceEndpoint ) . Should ( ) . BeNullOrEmpty ( ) ;
7877 }
78+
79+ public MessageExchangeProtocol GetProtocol ( Stream stream , ILog log )
80+ {
81+ return new MessageExchangeProtocol ( new MessageExchangeStream ( stream , new Type [ ] { } , log ) , log ) ;
82+ }
7983 }
8084}
0 commit comments