public void GetSearchIndexClient()
        {
            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 index     = service.GetSearchIndexClient(indexName);

            Assert.NotNull(index);
            Assert.AreEqual(endpoint, index.Endpoint);
            Assert.AreEqual(serviceName, index.ServiceName);
            Assert.AreEqual(indexName, index.IndexName);

            Assert.Throws <ArgumentNullException>(() => service.GetSearchIndexClient(null));
            Assert.Throws <ArgumentException>(() => service.GetSearchIndexClient(string.Empty));
        }
Beispiel #2
0
        public void Constructor()
        {
            var serviceName = "my-svc-name";
            var endpoint    = new Uri($"https://{serviceName}.search.windows.net");
            var service     = new SearchServiceClient(endpoint, new SearchApiKeyCredential("fake"));

            Assert.NotNull(service);
            Assert.AreEqual(endpoint, service.Endpoint);
            Assert.AreEqual(serviceName, service.ServiceName);

            var indexName = "my-index-name";
            var index     = service.GetSearchIndexClient(indexName);

            Assert.NotNull(index);
            Assert.AreEqual(endpoint, index.Endpoint);
            Assert.AreEqual(serviceName, index.ServiceName);
            Assert.AreEqual(indexName, index.IndexName);
        }
        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 client = resources.GetServiceClient(options);

            SearchIndexClient index = client.GetSearchIndexClient(resources.IndexName);

            _ = await index.GetDocumentCountAsync();

            Assert.AreEqual(1, custom.RequestCount);
        }