@@ -149,5 +149,50 @@ public async Task GeneratePolicyFragmentTemplates_GeneratesPolicyFragmentTemplat
149
149
policyFragment1 . Should ( ) . NotBeNull ( ) ;
150
150
policyFragment1 . Properties . Description . Should ( ) . Be ( "A policy fragment example 1" ) ;
151
151
}
152
+
153
+ [ Fact ]
154
+ public async Task GeneratePolicyFragmentTemplates_GeneratesPolicyFragmentTemplateForSingleApi_GivenDifferentPolicyFragmentIdCases ( )
155
+ {
156
+ // arrange
157
+ var currentTestDirectory = Path . Combine ( this . OutputDirectory , nameof ( GeneratePolicyFragmentTemplates_GeneratesPolicyFragmentTemplateForSingleApi ) ) ;
158
+
159
+ var extractorConfig = this . GetDefaultExtractorConsoleAppConfiguration (
160
+ apiName : "api" ) ;
161
+ var extractorParameters = new ExtractorParameters ( extractorConfig ) ;
162
+ var fileLocation = Path . Combine ( MockClientUtils . ApiClientJsonResponsesPath , "ApiManagementListPolicyFragments_success_response.json" ) ;
163
+ var mockedClient = await MockPolicyFragmentClient . GetMockedHttpPolicyFragmentClient ( new MockClientConfiguration ( responseFileLocation : fileLocation ) ) ;
164
+
165
+ var policExtractor = new PolicyExtractor ( this . GetTestLogger < PolicyExtractor > ( ) , null , new TemplateBuilder ( ) ) ;
166
+ var policyFragmentExtractor = new PolicyFragmentsExtractor ( this . GetTestLogger < PolicyFragmentsExtractor > ( ) , new TemplateBuilder ( ) , mockedClient , policExtractor ) ;
167
+
168
+ var extractorExecutor = ExtractorExecutor . BuildExtractorExecutor (
169
+ this . GetTestLogger < ExtractorExecutor > ( ) ,
170
+ policyFragmentsExtractor : policyFragmentExtractor ,
171
+ policyExtractor : policExtractor ) ;
172
+ extractorExecutor . SetExtractorParameters ( extractorParameters ) ;
173
+
174
+ var apiPolicies = new List < PolicyTemplateResource > ( )
175
+ {
176
+ new PolicyTemplateResource ( )
177
+ {
178
+ Properties = new PolicyTemplateProperties ( )
179
+ {
180
+ PolicyContent = "fragment-id=\" POLICYFRAGMENT1\" "
181
+ }
182
+ }
183
+ } ;
184
+ // act
185
+ var policyFragments = await extractorExecutor . GeneratePolicyFragmentsTemplateAsync ( apiPolicies , currentTestDirectory ) ;
186
+
187
+ // assert
188
+ File . Exists ( Path . Combine ( currentTestDirectory , extractorParameters . FileNames . PolicyFragments ) ) . Should ( ) . BeTrue ( ) ;
189
+
190
+ policyFragments . Parameters . Should ( ) . ContainKey ( ParameterNames . ApimServiceName ) ;
191
+ policyFragments . TypedResources . PolicyFragments . Count ( ) . Should ( ) . Be ( 1 ) ;
192
+
193
+ var policyFragment1 = policyFragments . TypedResources . PolicyFragments . First ( x => x . OriginalName . Equals ( "policyFragment1" ) ) ;
194
+ policyFragment1 . Should ( ) . NotBeNull ( ) ;
195
+ policyFragment1 . Properties . Description . Should ( ) . Be ( "A policy fragment example 1" ) ;
196
+ }
152
197
}
153
198
}
0 commit comments