Files
microsoft--semantic-kernel/dotnet/test/VectorData/AzureAISearch.ConformanceTests/Support/AzureAISearchTestEnvironment.cs
T
wehub-resource-sync b957a53def
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:21:23 +08:00

34 lines
1.3 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Text.RegularExpressions;
using Microsoft.Extensions.Configuration;
namespace AzureAISearch.ConformanceTests.Support;
#pragma warning disable CA1810 // Initialize all static fields when those fields are declared
internal static class AzureAISearchTestEnvironment
{
#pragma warning disable CA1308 // Normalize strings to uppercase
public static readonly string TestIndexPostfix = '-' + new Regex("[^a-zA-Z0-9]").Replace(Environment.MachineName.ToLowerInvariant(), "");
#pragma warning restore CA1308 // Normalize strings to uppercase
public static readonly string? ServiceUrl, ApiKey;
public static bool IsConnectionInfoDefined => ServiceUrl is not null;
static AzureAISearchTestEnvironment()
{
var configuration = new ConfigurationBuilder()
.AddJsonFile(path: "testsettings.json", optional: true)
.AddJsonFile(path: "testsettings.development.json", optional: true)
.AddEnvironmentVariables()
.AddUserSecrets<AzureAISearchUrlRequiredAttribute>()
.Build();
var azureAISearchSection = configuration.GetSection("AzureAISearch");
ServiceUrl = azureAISearchSection?["ServiceUrl"];
ApiKey = azureAISearchSection?["ApiKey"];
}
}