mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET: Add comprehensive test classes for extension methods in Microsoft.Agents.AI.Workflows.Declarative (#1555)
* Initial plan * Add test classes for extension methods Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Fix test issues and document bug in ExpandoObjectExtensions Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Address code review feedback - shorten Skip messages and add explanatory comments Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Replace Fields.ToDictionary with GetField calls and fix ExpandoObjectExtensions bug Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Update dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/DataValueExtensionsTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/DataValueExtensionsTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove unused using statement from DialogBaseExtensionsTests Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Add proper WrapWithBot tests using AdaptiveDialog and OnActivity Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Cleanup * Better * Better * One more test --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Chris Rickman <crickman@microsoft.com>
This commit is contained in:
co-authored by
crickman
Copilot
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Chris Rickman
parent
470cd109c0
commit
c72455508b
+11
-16
@@ -45,23 +45,17 @@ internal static class ChatMessageExtensions
|
||||
|
||||
public static IEnumerable<ChatMessage> ToChatMessages(this TableDataValue messages)
|
||||
{
|
||||
foreach (DataValue message in messages.Values)
|
||||
foreach (RecordDataValue record in messages.Values)
|
||||
{
|
||||
if (message is RecordDataValue record)
|
||||
DataValue sourceRecord = record;
|
||||
if (record.Properties.Count == 1 && record.Properties.TryGetValue("Value", out DataValue? singleColumn))
|
||||
{
|
||||
if (record.Properties.Count == 1 && record.Properties.TryGetValue("Value", out DataValue? singleColumn))
|
||||
{
|
||||
record = singleColumn as RecordDataValue ?? record;
|
||||
}
|
||||
ChatMessage? convertedMessage = record.ToChatMessage();
|
||||
if (convertedMessage is not null)
|
||||
{
|
||||
yield return convertedMessage;
|
||||
}
|
||||
sourceRecord = singleColumn;
|
||||
}
|
||||
else if (message is StringDataValue text)
|
||||
ChatMessage? convertedMessage = sourceRecord.ToChatMessage();
|
||||
if (convertedMessage is not null)
|
||||
{
|
||||
yield return ToChatMessage(text);
|
||||
yield return convertedMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +137,7 @@ internal static class ChatMessageExtensions
|
||||
private static ChatRole GetRole(this RecordDataValue message)
|
||||
{
|
||||
StringDataValue? roleValue = message.GetProperty<StringDataValue>(TypeSchema.Message.Fields.Role);
|
||||
if (roleValue is null || string.IsNullOrWhiteSpace(roleValue.Value))
|
||||
if (string.IsNullOrWhiteSpace(roleValue?.Value))
|
||||
{
|
||||
return ChatRole.User;
|
||||
}
|
||||
@@ -164,13 +158,13 @@ internal static class ChatMessageExtensions
|
||||
{
|
||||
foreach (RecordDataValue contentItem in content.Values)
|
||||
{
|
||||
StringDataValue? contentValue = contentItem?.GetProperty<StringDataValue>(TypeSchema.Message.Fields.ContentValue);
|
||||
StringDataValue? contentValue = contentItem.GetProperty<StringDataValue>(TypeSchema.Message.Fields.ContentValue);
|
||||
if (contentValue is null || string.IsNullOrWhiteSpace(contentValue.Value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
yield return
|
||||
contentItem?.GetProperty<StringDataValue>(TypeSchema.Message.Fields.ContentType)?.Value switch
|
||||
contentItem.GetProperty<StringDataValue>(TypeSchema.Message.Fields.ContentType)?.Value switch
|
||||
{
|
||||
TypeSchema.Message.ContentTypes.ImageUrl => GetImageContent(contentValue.Value),
|
||||
TypeSchema.Message.ContentTypes.ImageFile => new HostedFileContent(contentValue.Value),
|
||||
@@ -218,6 +212,7 @@ internal static class ChatMessageExtensions
|
||||
UriContent uriContent => CreateContentRecord(TypeSchema.Message.ContentTypes.ImageUrl, uriContent.Uri.ToString()),
|
||||
HostedFileContent fileContent => CreateContentRecord(TypeSchema.Message.ContentTypes.ImageFile, fileContent.FileId),
|
||||
TextContent textContent => CreateContentRecord(TypeSchema.Message.ContentTypes.Text, textContent.Text),
|
||||
DataContent dataContent => CreateContentRecord(TypeSchema.Message.ContentTypes.ImageUrl, dataContent.Uri),
|
||||
_ => []
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user