From f70423bd99911cc0bc80a57af098c5272ddcae36 Mon Sep 17 00:00:00 2001 From: Chris Rickman Date: Thu, 5 Mar 2026 02:45:27 -0800 Subject: [PATCH] Cleanup --- ...emoryChatHistoryProviderCompactionTests.cs | 269 ------------------ 1 file changed, 269 deletions(-) delete mode 100644 dotnet/tests/Microsoft.Agents.AI.UnitTests/Compaction/InMemoryChatHistoryProviderCompactionTests.cs diff --git a/dotnet/tests/Microsoft.Agents.AI.UnitTests/Compaction/InMemoryChatHistoryProviderCompactionTests.cs b/dotnet/tests/Microsoft.Agents.AI.UnitTests/Compaction/InMemoryChatHistoryProviderCompactionTests.cs deleted file mode 100644 index 95cfb88aaa..0000000000 --- a/dotnet/tests/Microsoft.Agents.AI.UnitTests/Compaction/InMemoryChatHistoryProviderCompactionTests.cs +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -// %%% SAVE - RE-ANALYZE -//using System.Collections.Generic; -//using System.Threading; -//using System.Threading.Tasks; -//using Microsoft.Agents.AI.Compaction; -//using Microsoft.Extensions.AI; -//using Moq; - -//namespace Microsoft.Agents.AI.UnitTests.Compaction; - -///// -///// Contains tests for the compaction integration with . -///// -//public class InMemoryChatHistoryProviderCompactionTests -//{ -// private static readonly AIAgent s_mockAgent = new Mock().Object; - -// private static AgentSession CreateMockSession() => new Mock().Object; - -// [Fact] -// public void Constructor_SetsCompactionStrategy_FromOptions() -// { -// // Arrange -// Mock strategy = new(); - -// // Act -// InMemoryChatHistoryProvider provider = new(new InMemoryChatHistoryProviderOptions -// { -// CompactionStrategy = strategy.Object, -// }); - -// // Assert -// Assert.Same(strategy.Object, provider.CompactionStrategy); -// } - -// [Fact] -// public void Constructor_CompactionStrategyIsNull_ByDefault() -// { -// // Arrange & Act -// InMemoryChatHistoryProvider provider = new(); - -// // Assert -// Assert.Null(provider.CompactionStrategy); -// } - -// [Fact] -// public async Task StoreChatHistoryAsync_AppliesCompaction_WhenStrategyConfiguredAsync() -// { -// // Arrange — mock strategy that excludes the first included non-system group -// Mock mockStrategy = new(); -// mockStrategy.Setup(s => s.CompactAsync(It.IsAny(), It.IsAny())) -// .Callback((groups, _) => -// { -// foreach (MessageGroup group in groups.Groups) -// { -// if (!group.IsExcluded && group.Kind != MessageGroupKind.System) -// { -// group.IsExcluded = true; -// group.ExcludeReason = "Mock compaction"; -// break; -// } -// } -// }) -// .ReturnsAsync(true); - -// InMemoryChatHistoryProvider provider = new(new InMemoryChatHistoryProviderOptions -// { -// CompactionStrategy = mockStrategy.Object, -// }); - -// AgentSession session = CreateMockSession(); - -// // Pre-populate with some messages -// List existingMessages = -// [ -// new ChatMessage(ChatRole.User, "First"), -// new ChatMessage(ChatRole.Assistant, "Response 1"), -// ]; -// provider.SetMessages(session, existingMessages); - -// // Invoke the store flow with additional messages -// List requestMessages = -// [ -// new ChatMessage(ChatRole.User, "Second"), -// ]; -// List responseMessages = -// [ -// new ChatMessage(ChatRole.Assistant, "Response 2"), -// ]; - -// ChatHistoryProvider.InvokedContext context = new(s_mockAgent, session, requestMessages, responseMessages); - -// // Act -// await provider.InvokedAsync(context); - -// // Assert - compaction should have removed one group -// List storedMessages = provider.GetMessages(session); -// Assert.Equal(3, storedMessages.Count); -// mockStrategy.Verify(s => s.CompactAsync(It.IsAny(), It.IsAny()), Times.Once); -// } - -// [Fact] -// public async Task StoreChatHistoryAsync_DoesNotCompact_WhenNoStrategyAsync() -// { -// // Arrange -// InMemoryChatHistoryProvider provider = new(); -// AgentSession session = CreateMockSession(); - -// List requestMessages = -// [ -// new ChatMessage(ChatRole.User, "Hello"), -// ]; -// List responseMessages = -// [ -// new ChatMessage(ChatRole.Assistant, "Hi!"), -// ]; - -// ChatHistoryProvider.InvokedContext context = new(s_mockAgent, session, requestMessages, responseMessages); - -// // Act -// await provider.InvokedAsync(context); - -// // Assert - all messages should be stored -// List storedMessages = provider.GetMessages(session); -// Assert.Equal(2, storedMessages.Count); -// } - -// [Fact] -// public async Task CompactStorageAsync_CompactsStoredMessagesAsync() -// { -// // Arrange — mock strategy that excludes the two oldest non-system groups -// Mock mockStrategy = new(); -// mockStrategy.Setup(s => s.CompactAsync(It.IsAny(), It.IsAny())) -// .Callback((groups, _) => -// { -// int excluded = 0; -// foreach (MessageGroup group in groups.Groups) -// { -// if (!group.IsExcluded && group.Kind != MessageGroupKind.System && excluded < 2) -// { -// group.IsExcluded = true; -// excluded++; -// } -// } -// }) -// .ReturnsAsync(true); - -// InMemoryChatHistoryProvider provider = new(new InMemoryChatHistoryProviderOptions -// { -// CompactionStrategy = mockStrategy.Object, -// }); - -// AgentSession session = CreateMockSession(); -// provider.SetMessages(session, -// [ -// new ChatMessage(ChatRole.User, "First"), -// new ChatMessage(ChatRole.Assistant, "Response 1"), -// new ChatMessage(ChatRole.User, "Second"), -// new ChatMessage(ChatRole.Assistant, "Response 2"), -// ]); - -// // Act -// bool result = await provider.CompactStorageAsync(session); - -// // Assert -// Assert.True(result); -// List messages = provider.GetMessages(session); -// Assert.Equal(2, messages.Count); -// mockStrategy.Verify(s => s.CompactAsync(It.IsAny(), It.IsAny()), Times.Once); -// } - -// [Fact] -// public async Task CompactStorageAsync_UsesProvidedStrategy_OverDefaultAsync() -// { -// // Arrange -// Mock defaultStrategy = new(); -// Mock overrideStrategy = new(); - -// overrideStrategy.Setup(s => s.CompactAsync(It.IsAny(), It.IsAny())) -// .Callback((groups, _) => -// { -// // Exclude all but the last group -// for (int i = 0; i < groups.Groups.Count - 1; i++) -// { -// groups.Groups[i].IsExcluded = true; -// } -// }) -// .ReturnsAsync(true); - -// InMemoryChatHistoryProvider provider = new(new InMemoryChatHistoryProviderOptions -// { -// CompactionStrategy = defaultStrategy.Object, -// }); - -// AgentSession session = CreateMockSession(); -// provider.SetMessages(session, -// [ -// new ChatMessage(ChatRole.User, "First"), -// new ChatMessage(ChatRole.User, "Second"), -// new ChatMessage(ChatRole.User, "Third"), -// ]); - -// // Act -// bool result = await provider.CompactStorageAsync(session, overrideStrategy.Object); - -// // Assert -// Assert.True(result); -// List messages = provider.GetMessages(session); -// Assert.Single(messages); -// Assert.Equal("Third", messages[0].Text); - -// // Verify the override was used, not the default -// overrideStrategy.Verify(s => s.CompactAsync(It.IsAny(), It.IsAny()), Times.Once); -// defaultStrategy.Verify(s => s.CompactAsync(It.IsAny(), It.IsAny()), Times.Never); -// } - -// [Fact] -// public async Task CompactStorageAsync_Throws_WhenNoStrategyAvailableAsync() -// { -// // Arrange -// InMemoryChatHistoryProvider provider = new(); -// AgentSession session = CreateMockSession(); - -// // Act & Assert -// await Assert.ThrowsAsync( -// () => provider.CompactStorageAsync(session)); -// } - -// [Fact] -// public async Task CompactStorageAsync_WithCustomStrategy_AppliesCustomLogicAsync() -// { -// // Arrange -// Mock mockStrategy = new(); -// mockStrategy.Setup(s => s.CompactAsync(It.IsAny(), It.IsAny())) -// .Callback((groups, _) => -// { -// // Exclude all user groups -// foreach (MessageGroup group in groups.Groups) -// { -// if (group.Kind == MessageGroupKind.User) -// { -// group.IsExcluded = true; -// } -// } -// }) -// .ReturnsAsync(true); - -// InMemoryChatHistoryProvider provider = new(); -// AgentSession session = CreateMockSession(); -// provider.SetMessages(session, -// [ -// new ChatMessage(ChatRole.System, "System"), -// new ChatMessage(ChatRole.User, "User message"), -// new ChatMessage(ChatRole.Assistant, "Response"), -// ]); - -// // Act -// bool result = await provider.CompactStorageAsync(session, mockStrategy.Object); - -// // Assert -// Assert.True(result); -// List messages = provider.GetMessages(session); -// Assert.Equal(2, messages.Count); -// Assert.Equal(ChatRole.System, messages[0].Role); -// Assert.Equal(ChatRole.Assistant, messages[1].Role); -// } -//}