@@ -558,5 +558,36 @@ public async Task Given_ServerDetails_WithEmptyRoutePrefix_When_RenderAsync_Invo
558
558
( ( string ) json ? . basePath ) . Should ( ) . BeEquivalentTo ( null ) ;
559
559
( ( string ) json ? . schemes [ 0 ] ) . Should ( ) . BeEquivalentTo ( scheme ) ;
560
560
}
561
+
562
+ [ DataTestMethod ]
563
+ [ DataRow ( "https" , "localhost" , "api" ) ]
564
+ [ DataRow ( "https" , "localhost" , "" ) ]
565
+ [ DataRow ( "https" , "localhost" , null ) ]
566
+ public async Task Given_ServerDetails_When_RenderAsync_Invoked_Then_It_Should_Return_Result ( string scheme , string host , string routePrefix )
567
+ {
568
+ var helper = new Mock < IDocumentHelper > ( ) ;
569
+
570
+ var url = $ "{ scheme } ://{ host } /{ routePrefix } ";
571
+ var uri = new Uri ( url ) ;
572
+ var req = new Mock < IHttpRequestDataObject > ( ) ;
573
+ req . SetupGet ( p => p . Scheme ) . Returns ( scheme ) ;
574
+
575
+ req . SetupGet ( p => p . Host ) . Returns ( new HostString ( host ) ) ;
576
+
577
+
578
+ var doc = new Document ( helper . Object ) ;
579
+
580
+ var result = await doc . InitialiseDocument ( )
581
+ . AddServer ( req . Object , routePrefix )
582
+ . RenderAsync ( OpenApiSpecVersion . OpenApi3_0 , OpenApiFormat . Json ) ;
583
+
584
+ dynamic json = JObject . Parse ( result ) ;
585
+
586
+ ( ( string ) json ? . host ) . Should ( ) . BeEquivalentTo ( null ) ;
587
+ ( ( string ) json ? . basePath ) . Should ( ) . BeEquivalentTo ( null ) ;
588
+ ( ( string ) json ? . schemes ) . Should ( ) . BeEquivalentTo ( null ) ;
589
+ ( ( string ) json ? . servers [ 0 ] . url ) . Should ( ) . BeEquivalentTo ( uri . AbsoluteUri ) ;
590
+ }
561
591
}
562
592
}
593
+
0 commit comments