1313
1414namespace Azure . Search . Documents . Tests
1515{
16+ [ ClientTestFixture ( SearchClientOptions . ServiceVersion . V2020_06_30 , SearchClientOptions . ServiceVersion . V2020_06_30_Preview ) ]
1617 public class SearchIndexerClientTests : SearchTestBase
1718 {
1819 public SearchIndexerClientTests ( bool async , SearchClientOptions . ServiceVersion serviceVersion )
@@ -40,7 +41,7 @@ public void DiagnosticsAreUnique()
4041 {
4142 // Make sure we're not repeating Header/Query names already defined
4243 // in the base ClientOptions
43- SearchClientOptions options = new SearchClientOptions ( ) ;
44+ SearchClientOptions options = new SearchClientOptions ( ServiceVersion ) ;
4445 Assert . IsEmpty ( GetDuplicates ( options . Diagnostics . LoggedHeaderNames ) ) ;
4546 Assert . IsEmpty ( GetDuplicates ( options . Diagnostics . LoggedQueryParameters ) ) ;
4647
@@ -66,7 +67,7 @@ public async Task CreateAzureBlobIndexer()
6667 {
6768 await using SearchResources resources = await SearchResources . CreateWithBlobStorageAndIndexAsync ( this , populate : true ) ;
6869
69- SearchIndexerClient serviceClient = resources . GetIndexerClient ( ) ;
70+ SearchIndexerClient serviceClient = resources . GetIndexerClient ( new SearchClientOptions ( ServiceVersion ) ) ;
7071
7172 // Create the Azure Blob data source and indexer.
7273 SearchIndexerDataSourceConnection dataSource = new SearchIndexerDataSourceConnection (
@@ -381,9 +382,19 @@ public async Task CrudSkillset()
381382 {
382383 await using SearchResources resources = await SearchResources . CreateWithBlobStorageAndIndexAsync ( this ) ;
383384
384- SearchIndexerClient client = resources . GetIndexerClient ( new SearchClientOptions ( ) ) ;
385+ SearchIndexerClient client = resources . GetIndexerClient ( new SearchClientOptions ( ServiceVersion ) ) ;
385386 string skillsetName = Recording . Random . GetName ( ) ;
386387
388+ SearchIndexerSkillset skillset = CreateSkillsetModel ( skillsetName , resources ) ;
389+
390+ // Create the skillset.
391+ SearchIndexerSkillset createdSkillset = await client . CreateSkillsetAsync ( skillset ) ;
392+
393+ await TestSkillsetAsync ( client , skillset , createdSkillset , skillsetName ) ;
394+ }
395+
396+ private SearchIndexerSkillset CreateSkillsetModel ( string skillsetName , SearchResources resources )
397+ {
387398 // Skills based on https://github.com/Azure-Samples/azure-search-sample-data/blob/master/hotelreviews/HotelReviews_skillset.json.
388399 SearchIndexerSkill skill1 = new SplitSkill (
389400 new [ ]
@@ -502,10 +513,8 @@ public async Task CrudSkillset()
502513 SourceContext = null ,
503514 } ;
504515
505- SearchIndexerKnowledgeStoreProjection projection1 = new ( ) ;
506- projection1 . Tables . Add ( table1 ) ;
507- projection1 . Tables . Add ( table2 ) ;
508- projection1 . Tables . Add ( table3 ) ;
516+ SearchIndexerKnowledgeStoreProjection projection1 = new ( )
517+ { Tables = { table1 , table2 , table3 } } ;
509518
510519 SearchIndexerKnowledgeStoreTableProjectionSelector table4 = new ( "hotelReviewsInlineDocument" )
511520 {
@@ -538,10 +547,8 @@ public async Task CrudSkillset()
538547 } ;
539548 table6 . Inputs . Add ( new ( "Keyphrases" ) { Source = "/document/reviews_text/pages/*/Keyphrases/*" , SourceContext = null } ) ;
540549
541- SearchIndexerKnowledgeStoreProjection projection2 = new ( ) ;
542- projection2 . Tables . Add ( table4 ) ;
543- projection2 . Tables . Add ( table5 ) ;
544- projection2 . Tables . Add ( table6 ) ;
550+ SearchIndexerKnowledgeStoreProjection projection2 = new ( )
551+ { Tables = { table4 , table5 , table6 } } ;
545552
546553 List < SearchIndexerKnowledgeStoreProjection > projections = new ( ) { projection1 , projection2 } ;
547554
@@ -551,9 +558,11 @@ public async Task CrudSkillset()
551558 KnowledgeStore = new SearchIndexerKnowledgeStore ( resources . StorageAccountConnectionString , projections ) ,
552559 } ;
553560
554- // Create the skillset.
555- SearchIndexerSkillset createdSkillset = await client . CreateSkillsetAsync ( skillset ) ;
561+ return skillset ;
562+ }
556563
564+ private async Task TestSkillsetAsync ( SearchIndexerClient client , SearchIndexerSkillset skillset , SearchIndexerSkillset createdSkillset , string skillsetName )
565+ {
557566 try
558567 {
559568 Assert . That ( createdSkillset , Is . EqualTo ( skillset ) . Using ( SearchIndexerSkillsetComparer . Shared ) ) ;
@@ -620,13 +629,13 @@ public async Task RoundtripAllSkills()
620629
621630 await using SearchResources resources = SearchResources . CreateWithNoIndexes ( this ) ;
622631
623- SearchIndexerClient client = resources . GetIndexerClient ( new SearchClientOptions ( ) ) ;
632+ SearchIndexerClient client = resources . GetIndexerClient ( new SearchClientOptions ( ServiceVersion ) ) ;
624633 string skillsetName = Recording . Random . GetName ( ) ;
625634
626635 // Enumerate all skills and create them with consistently fake input to test for nullability during deserialization.
627636 SearchIndexerSkill CreateSkill ( Type t , string [ ] inputNames , string [ ] outputNames )
628637 {
629- var inputs = inputNames . Select ( input => new InputFieldMappingEntry ( input ) { Source = "/document/content" } ) . ToList ( ) ;
638+ var inputs = inputNames . Select ( input => new InputFieldMappingEntry ( input ) { Source = "/document/content" } ) . ToList ( ) ;
630639 var outputs = outputNames . Select ( output => new OutputFieldMappingEntry ( output , targetName : Recording . Random . GetName ( ) ) ) . ToList ( ) ;
631640
632641 return t switch
0 commit comments