From 5e3df6cef07d41d4da146c4a62d0cb179789f322 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 19:56:03 +0000 Subject: [PATCH 1/3] Initial plan From 1c7c9726ae7679d81114a395d070c3f432fc056b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:03:08 +0000 Subject: [PATCH 2/3] Make Cosmos DB tests read COSMOSDB_ENDPOINT and COSMOSDB_KEY from environment variables Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> --- .../CosmosChatHistoryProviderTests.cs | 6 +++--- .../CosmosCheckpointStoreTests.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs index 4c142d3c1e..8f805e8517 100644 --- a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs @@ -43,9 +43,9 @@ public sealed class CosmosChatHistoryProviderTests : IAsyncLifetime, IDisposable private static AgentSession CreateMockSession() => new Moq.Mock().Object; - // Cosmos DB Emulator connection settings - private const string EmulatorEndpoint = "https://localhost:8081"; - private const string EmulatorKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; + // Cosmos DB Emulator connection settings (can be overridden via COSMOSDB_ENDPOINT and COSMOSDB_KEY environment variables) + private static readonly string EmulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081"; + private static readonly string EmulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; private const string TestContainerId = "ChatMessages"; private const string HierarchicalTestContainerId = "HierarchicalChatMessages"; // Use unique database ID per test class instance to avoid conflicts diff --git a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs index f1f840cebf..054bb48de4 100644 --- a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs @@ -28,9 +28,9 @@ namespace Microsoft.Agents.AI.CosmosNoSql.UnitTests; [Collection("CosmosDB")] public class CosmosCheckpointStoreTests : IAsyncLifetime, IDisposable { - // Cosmos DB Emulator connection settings - private const string EmulatorEndpoint = "https://localhost:8081"; - private const string EmulatorKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; + // Cosmos DB Emulator connection settings (can be overridden via COSMOSDB_ENDPOINT and COSMOSDB_KEY environment variables) + private static readonly string EmulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081"; + private static readonly string EmulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; private const string TestContainerId = "Checkpoints"; // Use unique database ID per test class instance to avoid conflicts #pragma warning disable CA1802 // Use literals where appropriate From ad8949ccc38bddcefea054a86adfdd788b61306e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 20:15:51 +0000 Subject: [PATCH 3/3] Rename EmulatorEndpoint/EmulatorKey static fields to use s_ prefix convention Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> --- .../CosmosChatHistoryProviderTests.cs | 12 ++++++------ .../CosmosCheckpointStoreTests.cs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs index 8f805e8517..0ab605e4d6 100644 --- a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs @@ -44,8 +44,8 @@ public sealed class CosmosChatHistoryProviderTests : IAsyncLifetime, IDisposable private static AgentSession CreateMockSession() => new Moq.Mock().Object; // Cosmos DB Emulator connection settings (can be overridden via COSMOSDB_ENDPOINT and COSMOSDB_KEY environment variables) - private static readonly string EmulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081"; - private static readonly string EmulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; + private static readonly string s_emulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081"; + private static readonly string s_emulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; private const string TestContainerId = "ChatMessages"; private const string HierarchicalTestContainerId = "HierarchicalChatMessages"; // Use unique database ID per test class instance to avoid conflicts @@ -67,12 +67,12 @@ public async Task InitializeAsync() // Set COSMOS_PRESERVE_CONTAINERS=true to keep containers and data for inspection this._preserveContainer = string.Equals(Environment.GetEnvironmentVariable("COSMOS_PRESERVE_CONTAINERS"), "true", StringComparison.OrdinalIgnoreCase); - this._connectionString = $"AccountEndpoint={EmulatorEndpoint};AccountKey={EmulatorKey}"; + this._connectionString = $"AccountEndpoint={s_emulatorEndpoint};AccountKey={s_emulatorKey}"; try { // Only create CosmosClient for test setup - the actual tests will use connection string constructors - this._setupClient = new CosmosClient(EmulatorEndpoint, EmulatorKey); + this._setupClient = new CosmosClient(s_emulatorEndpoint, s_emulatorKey); // Test connection by attempting to create database var databaseResponse = await this._setupClient.CreateDatabaseIfNotExistsAsync(s_testDatabaseId); @@ -497,7 +497,7 @@ public void Constructor_WithHierarchicalEndpoint_ShouldCreateInstance() // Act TokenCredential credential = new DefaultAzureCredential(); - using var provider = new CosmosChatHistoryProvider(EmulatorEndpoint, credential, s_testDatabaseId, HierarchicalTestContainerId, + using var provider = new CosmosChatHistoryProvider(s_emulatorEndpoint, credential, s_testDatabaseId, HierarchicalTestContainerId, _ => new CosmosChatHistoryProvider.State("session-789", "tenant-123", "user-456")); // Assert @@ -513,7 +513,7 @@ public void Constructor_WithHierarchicalCosmosClient_ShouldCreateInstance() // Arrange & Act this.SkipIfEmulatorNotAvailable(); - using var cosmosClient = new CosmosClient(EmulatorEndpoint, EmulatorKey); + using var cosmosClient = new CosmosClient(s_emulatorEndpoint, s_emulatorKey); using var provider = new CosmosChatHistoryProvider(cosmosClient, s_testDatabaseId, HierarchicalTestContainerId, _ => new CosmosChatHistoryProvider.State("session-789", "tenant-123", "user-456")); diff --git a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs index 054bb48de4..0974045a9d 100644 --- a/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs @@ -29,8 +29,8 @@ namespace Microsoft.Agents.AI.CosmosNoSql.UnitTests; public class CosmosCheckpointStoreTests : IAsyncLifetime, IDisposable { // Cosmos DB Emulator connection settings (can be overridden via COSMOSDB_ENDPOINT and COSMOSDB_KEY environment variables) - private static readonly string EmulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081"; - private static readonly string EmulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; + private static readonly string s_emulatorEndpoint = Environment.GetEnvironmentVariable("COSMOSDB_ENDPOINT") ?? "https://localhost:8081"; + private static readonly string s_emulatorKey = Environment.GetEnvironmentVariable("COSMOSDB_KEY") ?? "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; private const string TestContainerId = "Checkpoints"; // Use unique database ID per test class instance to avoid conflicts #pragma warning disable CA1802 // Use literals where appropriate @@ -64,11 +64,11 @@ public async Task InitializeAsync() // Set COSMOS_PRESERVE_CONTAINERS=true to keep containers and data for inspection this._preserveContainer = string.Equals(Environment.GetEnvironmentVariable("COSMOS_PRESERVE_CONTAINERS"), "true", StringComparison.OrdinalIgnoreCase); - this._connectionString = $"AccountEndpoint={EmulatorEndpoint};AccountKey={EmulatorKey}"; + this._connectionString = $"AccountEndpoint={s_emulatorEndpoint};AccountKey={s_emulatorKey}"; try { - this._cosmosClient = new CosmosClient(EmulatorEndpoint, EmulatorKey); + this._cosmosClient = new CosmosClient(s_emulatorEndpoint, s_emulatorKey); // Test connection by attempting to create database this._database = await this._cosmosClient.CreateDatabaseIfNotExistsAsync(s_testDatabaseId);