@@ -129,5 +129,74 @@ public async Task GenerateTagTemplates_GetApiOperationRelated_ProperlyLaysTheInf
129129 resources . Tags . Any ( x => x . Name . Contains ( MockTagClient . OperationTagName1 ) ) . Should ( ) . BeTrue ( ) ;
130130 resources . Tags . Any ( x => x . Name . Contains ( MockTagClient . OperationTagName2 ) ) . Should ( ) . BeTrue ( ) ;
131131 }
132+
133+ [ Fact ]
134+ public async Task GenerateTagTemplates_GetApiRelatedTags_ProperlyLaysTheInformation ( )
135+ {
136+ // arrange
137+ var currentTestDirectory = Path . Combine ( this . OutputDirectory , nameof ( GenerateTagTemplates_GetApiRelatedTags_ProperlyLaysTheInformation ) ) ;
138+
139+ var extractorConfig = this . GetDefaultExtractorConsoleAppConfiguration ( ) ;
140+ var extractorParameters = new ExtractorParameters ( extractorConfig ) ;
141+
142+ var mockedTagClient = MockTagClient . GetMockedApiClientWithDefaultValues ( ) ;
143+ var tagExtractor = new TagExtractor (
144+ this . GetTestLogger < TagExtractor > ( ) ,
145+ mockedTagClient ,
146+ new TemplateBuilder ( ) ) ;
147+
148+ var extractorExecutor = ExtractorExecutor . BuildExtractorExecutor (
149+ this . GetTestLogger < ExtractorExecutor > ( ) ,
150+ tagExtractor : tagExtractor ) ;
151+ extractorExecutor . SetExtractorParameters ( extractorParameters ) ;
152+
153+ var apiTemplateResources = new ApiTemplateResources
154+ {
155+ Tags = new List < TagTemplateResource >
156+ {
157+ new TagTemplateResource
158+ {
159+ Name = $ "parameters'/{ MockTagClient . TagName1 } '"
160+ } ,
161+ new TagTemplateResource
162+ {
163+ Name = $ "parameters/{ MockTagClient . TagName2 } '"
164+ }
165+ } ,
166+ ApiOperationsTags = new List < TagTemplateResource >
167+ {
168+ new TagTemplateResource
169+ {
170+ Name = $ "parameters'/{ MockTagClient . OperationTagName1 } '"
171+ } ,
172+ new TagTemplateResource
173+ {
174+ Name = $ "parameters/{ MockTagClient . OperationTagName2 } '"
175+ }
176+ }
177+ } ;
178+ var productTemplateResources = new ProductTemplateResources ( ) ;
179+
180+ var tagTemplate = await extractorExecutor . GenerateTagTemplateAsync (
181+ "apiName1" ,
182+ apiTemplateResources ,
183+ productTemplateResources ,
184+ currentTestDirectory ) ;
185+
186+ // assert
187+ File . Exists ( Path . Combine ( currentTestDirectory , extractorParameters . FileNames . Tags ) ) . Should ( ) . BeTrue ( ) ;
188+
189+ tagTemplate . Parameters . Should ( ) . ContainKey ( ParameterNames . ApimServiceName ) ;
190+ tagTemplate . TypedResources . Tags . Count ( ) . Should ( ) . Be ( 4 ) ;
191+ tagTemplate . Resources . Count ( ) . Should ( ) . Be ( 4 ) ;
192+
193+ var resources = tagTemplate . TypedResources ;
194+
195+ resources . Tags . Any ( x => x . Name . Contains ( $ "/{ MockTagClient . OperationTagName1 } '") ) . Should ( ) . BeTrue ( ) ;
196+ resources . Tags . Any ( x => x . Name . Contains ( $ "/{ MockTagClient . OperationTagName2 } '") ) . Should ( ) . BeTrue ( ) ;
197+ resources . Tags . Any ( x => x . Name . Contains ( $ "/{ MockTagClient . TagName1 } '") ) . Should ( ) . BeTrue ( ) ;
198+ resources . Tags . Any ( x => x . Name . Contains ( $ "/{ MockTagClient . TagName2 } '") ) . Should ( ) . BeTrue ( ) ;
199+ }
200+
132201 }
133202}
0 commit comments