11using PactNet . Drivers ;
22using PactNet . Drivers . Http ;
33using PactNet . Drivers . Message ;
4+ using PactNet . Drivers . Plugins ;
45using PactNet . Interop ;
56using PactNet . Models ;
67
@@ -23,7 +24,8 @@ public static class PactExtensions
2324 /// It is advised that the port is not specified whenever possible to allow PactNet to allocate a port dynamically
2425 /// and ensure there are no port clashes
2526 /// </remarks>
26- public static IPactBuilderV2 WithHttpInteractions ( this IPactV2 pact , int ? port = null , IPAddress host = IPAddress . Loopback )
27+ public static IPactBuilderV2 WithHttpInteractions ( this IPactV2 pact , int ? port = null ,
28+ IPAddress host = IPAddress . Loopback )
2729 {
2830 pact . Config . LogLevel . LogToBuffer ( ) ;
2931
@@ -46,7 +48,8 @@ public static IPactBuilderV2 WithHttpInteractions(this IPactV2 pact, int? port =
4648 /// It is advised that the port is not specified whenever possible to allow PactNet to allocate a port dynamically
4749 /// and ensure there are no port clashes
4850 /// </remarks>
49- public static IPactBuilderV3 WithHttpInteractions ( this IPactV3 pact , int ? port = null , IPAddress host = IPAddress . Loopback )
51+ public static IPactBuilderV3 WithHttpInteractions ( this IPactV3 pact , int ? port = null ,
52+ IPAddress host = IPAddress . Loopback )
5053 {
5154 pact . Config . LogLevel . LogToBuffer ( ) ;
5255
@@ -69,7 +72,8 @@ public static IPactBuilderV3 WithHttpInteractions(this IPactV3 pact, int? port =
6972 /// It is advised that the port is not specified whenever possible to allow PactNet to allocate a port dynamically
7073 /// and ensure there are no port clashes
7174 /// </remarks>
72- public static IPactBuilderV4 WithHttpInteractions ( this IPactV4 pact , int ? port = null , IPAddress host = IPAddress . Loopback )
75+ public static IPactBuilderV4 WithHttpInteractions ( this IPactV4 pact , int ? port = null ,
76+ IPAddress host = IPAddress . Loopback )
7377 {
7478 pact . Config . LogLevel . LogToBuffer ( ) ;
7579
@@ -111,5 +115,26 @@ public static IMessagePactBuilderV4 WithMessageInteractions(this IPactV4 pact)
111115 var builder = new MessagePactBuilder ( messagePact , pact . Config , PactSpecification . V4 ) ;
112116 return builder ;
113117 }
118+
119+ /// <summary>
120+ /// Establish a new pact with synchronous plugin interactions.
121+ /// </summary>
122+ /// <param name="pact"></param>
123+ /// <param name="pluginName">Plugin name</param>
124+ /// <param name="pluginVersion">Plugin version</param>
125+ /// <param name="transport">The transport to use (i.e. http, https, grpc). Must be a valid UTF-8 NULL-terminated string, or NULL or empty, in which case http will be used.</param>
126+ /// <param name="port">Port for the mock server. If null, one will be assigned automatically</param>
127+ /// <param name="host">Host for the mock server</param>
128+ /// <returns></returns>
129+ public static ISynchronousPluginPactBuilderV4 WithSynchronousPluginInteractions ( this IPactV4 pact ,
130+ string pluginName , string pluginVersion , string transport = null , int ? port = null ,
131+ IPAddress host = IPAddress . Loopback )
132+ {
133+ pact . Config . LogLevel . LogToBuffer ( ) ;
134+ IPactDriver driver = new PactDriver ( ) ;
135+ var pluginDriver = driver . NewPluginPact ( pact . Consumer , pact . Provider , pluginName , pluginVersion ,
136+ PactSpecification . V4 ) ;
137+ return new SynchronousPluginPactBuilder ( pluginDriver , pact . Config , port , host , transport ) ;
138+ }
114139 }
115140}
0 commit comments