public void GetSearchClient() { var serviceName = "my-svc-name"; var endpoint = new Uri($"https://{serviceName}.search.windows.net"); var service = new SearchServiceClient(endpoint, new AzureKeyCredential("fake")); var indexName = "my-index-name"; var client = service.GetSearchClient(indexName); Assert.NotNull(client); Assert.AreEqual(endpoint, client.Endpoint); Assert.AreEqual(serviceName, client.ServiceName); Assert.AreEqual(indexName, client.IndexName); Assert.Throws <ArgumentNullException>(() => service.GetSearchClient(null)); Assert.Throws <ArgumentException>(() => service.GetSearchClient(string.Empty)); }
public async Task IndexSharesPipeline() { await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this); TestPipelinePolicy custom = new TestPipelinePolicy(); Assert.AreEqual(0, custom.RequestCount); SearchClientOptions options = new SearchClientOptions(ServiceVersion); options.AddPolicy(custom, HttpPipelinePosition.PerCall); SearchServiceClient serviceClient = resources.GetServiceClient(options); SearchClient client = serviceClient.GetSearchClient(resources.IndexName); _ = await client.GetDocumentCountAsync(); Assert.AreEqual(1, custom.RequestCount); }