public void GetServiceStatsReturnsCorrectDefinition() { Run(() => { SearchServiceClient searchClient = Data.GetSearchServiceClient(); var expectedStats = new ServiceStatistics { Counters = new ServiceCounters { DocumentCounter = new ResourceCounter(0, null), IndexCounter = new ResourceCounter(0, 3), IndexerCounter = new ResourceCounter(0, 3), DataSourceCounter = new ResourceCounter(0, 3), StorageSizeCounter = new ResourceCounter(0, 52428800), SynonymMapCounter = new ResourceCounter(0, 3) }, Limits = new ServiceLimits { MaxFieldsPerIndex = 1000, MaxFieldNestingDepthPerIndex = 10, MaxComplexCollectionFieldsPerIndex = 40 } }; ServiceStatistics stats = searchClient.GetServiceStatistics(); Assert.Equal(expectedStats, stats, new ModelComparer <ServiceStatistics>()); }); }
public async Task CreateClient() { await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this); Environment.SetEnvironmentVariable("SEARCH_ENDPOINT", resources.Endpoint.ToString()); Environment.SetEnvironmentVariable("SEARCH_API_KEY", resources.PrimaryApiKey); #region Snippet:Azure_Search_Tests_Samples_CreateClient // Get the service endpoint and API key from the environment Uri endpoint = new Uri(Environment.GetEnvironmentVariable("SEARCH_ENDPOINT")); AzureKeyCredential credential = new AzureKeyCredential( Environment.GetEnvironmentVariable("SEARCH_API_KEY")); // Create a new SearchServiceClient SearchServiceClient search = new SearchServiceClient(endpoint, credential); /*@@*/ search = InstrumentClient(new SearchServiceClient(endpoint, credential, GetSearchClientOptions())); // Perform an operation Response <SearchServiceStatistics> stats = search.GetServiceStatistics(); Console.WriteLine($"You are using {stats.Value.Counters.IndexCounter.Usage} indexes."); #endregion Snippet:Azure_Search_Tests_Samples_CreateClient Assert.AreEqual(1, stats.Value.Counters.IndexCounter.Usage); }