@@ -100,9 +100,58 @@ public void Create_TwoAggregateRoutes_HappyPath()
100
100
AssertResultByIndex ( 1 ) ;
101
101
}
102
102
103
- private void AssertResultByIndex ( int i )
103
+ [ Theory ]
104
+ [ Trait ( "Feat" , "1389" ) ]
105
+ [ InlineData ( nameof ( HttpMethod . Get ) ) ]
106
+ [ InlineData ( nameof ( HttpMethod . Post ) ) ]
107
+ public void SetUpAggregateRoute_NoUpstreamHttpMethod_DefaultVerbIsAssigned ( string httpVerb )
104
108
{
105
- _result [ i ] . UpstreamHttpMethod . ShouldContain ( x => x == HttpMethod . Get ) ;
109
+ // Arrange
110
+ _fileConfiguration = new FileConfiguration
111
+ {
112
+ Aggregates = new List < FileAggregateRoute >
113
+ {
114
+ new ( )
115
+ {
116
+ RouteKeys = new List < string > { "key1" , "key2" } ,
117
+ } ,
118
+ new ( )
119
+ {
120
+ RouteKeys = new List < string > { "key3" , "key4" } ,
121
+ UpstreamHttpMethod = new ( ) { httpVerb } , // wanted verb
122
+ } ,
123
+ } ,
124
+ } ;
125
+ _routes = new List < Route >
126
+ {
127
+ new RouteBuilder ( ) . WithDownstreamRoute ( new DownstreamRouteBuilder ( ) . WithKey ( "key1" ) . Build ( ) ) . Build ( ) ,
128
+ new RouteBuilder ( ) . WithDownstreamRoute ( new DownstreamRouteBuilder ( ) . WithKey ( "key2" ) . Build ( ) ) . Build ( ) ,
129
+ new RouteBuilder ( ) . WithDownstreamRoute ( new DownstreamRouteBuilder ( ) . WithKey ( "key3" ) . Build ( ) ) . Build ( ) ,
130
+ new RouteBuilder ( ) . WithDownstreamRoute ( new DownstreamRouteBuilder ( ) . WithKey ( "key4" ) . Build ( ) ) . Build ( ) ,
131
+ } ;
132
+ GivenTheUtpCreatorReturns ( ) ;
133
+ GivenTheUhtpCreatorReturns ( ) ;
134
+
135
+ // Act
136
+ _result = _creator . Create ( _fileConfiguration , _routes ) ;
137
+
138
+ // Assert
139
+ ThenTheUtpCreatorIsCalledCorrectly ( ) ;
140
+ _result . ShouldNotBeNull ( ) . Count . ShouldBe ( 2 ) ;
141
+ AssertRoute ( 0 , FileAggregateRoute . DefaultHttpMethod ) ; // default verb scenario
142
+ AssertRoute ( 1 , new HttpMethod ( httpVerb ) ) ; // // wanted verb scenario
143
+ }
144
+
145
+ private void AssertRoute ( int i , HttpMethod expected )
146
+ {
147
+ _result [ i ] . UpstreamHttpMethod . ShouldContain ( x => x == expected ) ;
148
+ AssertResultByIndex ( i , expected ) ;
149
+ }
150
+
151
+ private void AssertResultByIndex ( int i , HttpMethod method = null )
152
+ {
153
+ method ??= FileAggregateRoute . DefaultHttpMethod ;
154
+ _result [ i ] . UpstreamHttpMethod . ShouldContain ( x => x == method ) ;
106
155
_result [ i ] . UpstreamHost . ShouldBe ( _fileConfiguration . Aggregates [ i ] . UpstreamHost ) ;
107
156
_result [ i ] . UpstreamTemplatePattern . ShouldBe ( _aggregateUtp [ i ] ) ;
108
157
_result [ i ] . UpstreamHeaderTemplates . ShouldBe ( _headerTemplates [ i ] ) ;
0 commit comments