@@ -548,7 +548,7 @@ public void HttpTesterClientBrochureUploadMultipartPresent_Fails()
548
548
. WithMultipart ( "Metadata.Year" , "2000" )
549
549
. WithMultipart ( "Metadata.Name" , "Brochure 2000" ) ;
550
550
551
- var exception = Assert . Throws < QAToolKitEngineHttpTesterException > ( ( ) => client . WithJsonBody < string > ( "1234" ) ) ;
551
+ var exception = Assert . Throws < QAToolKitEngineHttpTesterException > ( ( ) => client . WithJsonBody < string > ( "1234" ) ) ;
552
552
Assert . StartsWith ( "Body multipart/form-data already defined" , exception . Message ) ;
553
553
}
554
554
}
@@ -617,5 +617,74 @@ public async Task HttpTesterClientAddGetHttpRequest_Success()
617
617
Assert . True ( response . IsSuccessStatusCode ) ;
618
618
}
619
619
}
620
+
621
+ [ Fact ]
622
+ public async Task HttpTesterClientGetBikeByIdRequest_Success ( )
623
+ {
624
+ var urlSource = new SwaggerUrlSource ( options =>
625
+ {
626
+ options . AddBaseUrl ( new Uri ( "https://qatoolkitapi.azurewebsites.net/" ) ) ;
627
+ options . AddRequestFilters ( new RequestFilter ( )
628
+ {
629
+ EndpointNameWhitelist = new string [ ] { "GetBike" }
630
+ } ) ;
631
+ options . UseSwaggerExampleValues = true ;
632
+ } ) ;
633
+
634
+ var requests = await urlSource . Load ( new Uri [ ] {
635
+ new Uri ( "https://qatoolkitapi.azurewebsites.net/swagger/v2/swagger.json" )
636
+ } ) ;
637
+
638
+ using ( var client = new HttpTesterClient ( ) )
639
+ {
640
+ var response = await client
641
+ . CreateHttpRequest ( requests . FirstOrDefault ( ) )
642
+ . WithPathReplacementValues ( new Dictionary < string , string > ( ) { { "id" , "2" } } )
643
+ . WithQueryParams ( new Dictionary < string , string > ( ) { { "api-version" , "2" } } )
644
+ . Start ( ) ;
645
+
646
+ var msg = await response . GetResponseBody < Bicycle > ( ) ;
647
+
648
+ var expecterResponse = BicycleFixture . GetCannondale ( ) . ToExpectedObject ( ) ;
649
+ expecterResponse . ShouldEqual ( msg ) ;
650
+
651
+ Assert . True ( client . Duration < 2000 ) ;
652
+ Assert . True ( response . IsSuccessStatusCode ) ;
653
+ }
654
+ }
655
+
656
+ [ Fact ]
657
+ public async Task HttpTesterClientGetBikesByTypeHttpRequest_Success ( )
658
+ {
659
+ var urlSource = new SwaggerUrlSource ( options =>
660
+ {
661
+ options . AddBaseUrl ( new Uri ( "https://qatoolkitapi.azurewebsites.net/" ) ) ;
662
+ options . AddRequestFilters ( new RequestFilter ( )
663
+ {
664
+ EndpointNameWhitelist = new string [ ] { "GetAllBikes" }
665
+ } ) ;
666
+ options . UseSwaggerExampleValues = true ;
667
+ } ) ;
668
+
669
+ var requests = await urlSource . Load ( new Uri [ ] {
670
+ new Uri ( "https://qatoolkitapi.azurewebsites.net/swagger/v2/swagger.json" )
671
+ } ) ;
672
+
673
+ using ( var client = new HttpTesterClient ( ) )
674
+ {
675
+ var response = await client
676
+ . CreateHttpRequest ( requests . FirstOrDefault ( ) )
677
+ . WithQueryParams ( new Dictionary < string , string > ( ) { { "api-version" , "2" } , { "bicycleType" , "1" } } )
678
+ . Start ( ) ;
679
+
680
+ var msg = await response . GetResponseBody < List < Bicycle > > ( ) ;
681
+
682
+ var expecterResponse = BicycleFixture . GetCannondaleArray ( ) . ToExpectedObject ( ) ;
683
+ expecterResponse . ShouldEqual ( msg ) ;
684
+
685
+ Assert . True ( client . Duration < 2000 ) ;
686
+ Assert . True ( response . IsSuccessStatusCode ) ;
687
+ }
688
+ }
620
689
}
621
690
}
0 commit comments