diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/AzureStorageEmulatorAvailabilityHelper.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/AzureStorageEmulatorAvailabilityHelper.cs index 906acfd083..4ebc607cc9 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/AzureStorageEmulatorAvailabilityHelper.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/AzureStorageEmulatorAvailabilityHelper.cs @@ -45,7 +45,7 @@ internal static class AzureStorageEmulatorAvailabilityHelper public static async Task SkipIfNotAvailableAsync() { - var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)); + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)); bool isAvailable = await IsAvailableAsync(cts.Token); Skip.IfNot(isAvailable, "Azurite / Azure Storage Emulator is not running. Start Azurite to run these tests."); } diff --git a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/Mock/MockChatClient.cs b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/Mock/MockChatClient.cs index e18c7d0633..b99e0f5011 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/Mock/MockChatClient.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Hosting.AzureStorage.UnitTests/Mock/MockChatClient.cs @@ -23,12 +23,7 @@ internal sealed class MockChatClient : IChatClient { await Task.Yield(); - List messageList = messages.ToList(); - ChatMessage lastUserMessage = messageList.LastOrDefault(m => m.Role == ChatRole.User) - ?? new ChatMessage(ChatRole.User, "No user message"); - ChatMessage responseMessage = new(ChatRole.Assistant, $"Response #{this._responsesCounter++}"); - return new ChatResponse([responseMessage]); } @@ -39,11 +34,7 @@ internal sealed class MockChatClient : IChatClient { await Task.Yield(); - List messageList = messages.ToList(); - ChatMessage lastUserMessage = messageList.LastOrDefault(m => m.Role == ChatRole.User) - ?? new ChatMessage(ChatRole.User, "No user message"); - - string responseText = $"Mock response to: {lastUserMessage.Text}"; + var responseText = $"Response #{this._responsesCounter++}"; yield return new ChatResponseUpdate(ChatRole.Assistant, responseText); }