1+ #if ! ( NET452  ||  NET461  ||  NETCOREAPP3_1 ) 
12// Copyright © WireMock.Net 
23
34using  System . IO ; 
45using  System . Net ; 
56using  System . Text ; 
7+ using  System . Threading . Tasks ; 
68using  FluentAssertions ; 
79using  Newtonsoft . Json ; 
810using  Newtonsoft . Json . Linq ; 
11+ using  VerifyXunit ; 
912using  WireMock . Matchers ; 
1013using  WireMock . RequestBuilders ; 
1114using  WireMock . ResponseBuilders ; 
1417
1518namespace  WireMock . Net . Tests . Pact ; 
1619
20+ [ UsesVerify ] 
1721public  class  PactTests 
1822{ 
1923    [ Fact ] 
20-     public  void  SavePact_Get_Request_And_Response_WithBodyAsJson ( ) 
24+     public  async   Task  SavePact_Get_Request_And_Response_WithBodyAsJson ( ) 
2125    { 
2226        var  server  =  WireMockServer . Start ( ) ; 
2327        server 
@@ -46,12 +50,34 @@ public void SavePact_Get_Request_And_Response_WithBodyAsJson()
4650
4751        var  folder  =  Path . Combine ( "../../../" ,  "Pact" ,  "files" ) ; 
4852        var  file  =  "pact-get.json" ; 
53+         var  path  =  Path . Combine ( folder ,  file ) ; 
4954
5055        // Act 
5156        server . SavePact ( folder ,  file ) ; 
5257
5358        // Assert 
54-         File . ReadAllBytes ( Path . Combine ( folder ,  file ) ) . Length . Should ( ) . BeGreaterThan ( 1 ) ; 
59+         await  Verifier . VerifyFile ( path ) ; 
60+     } 
61+ 
62+     [ Fact ] 
63+     public  async  Task  SavePact_Post_Request_WithDescription ( ) 
64+     { 
65+         var  server  =  WireMockServer . Start ( ) ; 
66+         server 
67+             . Given ( Request . Create ( ) . UsingPost ( ) . WithPath ( "/tester" ) ) 
68+             . WithTitle ( "POST something" ) 
69+             . WithDescription ( "A POST request to change something" ) 
70+             . RespondWith ( Response . Create ( ) . WithStatusCode ( HttpStatusCode . OK ) ) ; 
71+ 
72+         var  folder  =  Path . Combine ( "../../../" ,  "Pact" ,  "files" ) ; 
73+         var  file  =  "pact-post.json" ; 
74+         var  path  =  Path . Combine ( folder ,  file ) ; 
75+ 
76+         // Act 
77+         server . SavePact ( folder ,  file ) ; 
78+ 
79+         // Assert 
80+         await  Verifier . VerifyFile ( path ) ; 
5581    } 
5682
5783    [ Fact ] 
@@ -219,4 +245,5 @@ public void SavePact_Multiple_Requests()
219245        // Assert 
220246        File . ReadAllBytes ( Path . Combine ( folder ,  file ) ) . Length . Should ( ) . BeGreaterThan ( 1 ) ; 
221247    } 
222- } 
248+ } 
249+ #endif
0 commit comments