Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,67 @@ public void ToAgentResponseUpdatesWithAdditionalPropertiesOnlyProducesSingleUpda
Assert.NotNull(update.AdditionalProperties);
Assert.Equal("value", update.AdditionalProperties!["key"]);
}

[Fact]
public void Constructor_WithNullChatResponse_ThrowsArgumentNullException()
{
// Act & Assert
Assert.Throws<ArgumentNullException>("response", () => new AgentResponse((ChatResponse)null!));
}

[Fact]
public void Text_WithOnlyNonTextContent_ReturnsEmptyString()
{
// Arrange
AgentResponse response = new(
[
new ChatMessage(
ChatRole.Assistant,
[
new DataContent("data:image/png;base64,aGVsbG8="),
new FunctionCallContent("callId1", "fc1"),
new FunctionResultContent("callId1", "result"),
])
]);

// Act & Assert
Assert.Equal(string.Empty, response.Text);
}

[Fact]
public void Text_AfterSettingMessagesToNull_ReturnsEmptyString()
{
// Arrange
AgentResponse response = new(new ChatMessage(ChatRole.Assistant, "hello"));

// Act
response.Messages = null!;

// Assert
Assert.Equal(string.Empty, response.Text);
}

[Fact]
public void ToAgentResponseUpdates_WithMultipleMessages_PreservesOrder()
{
// Arrange
AgentResponse response = new(
[
new ChatMessage(ChatRole.Assistant, "first") { MessageId = "msg1" },
new ChatMessage(ChatRole.Assistant, "second") { MessageId = "msg2" },
new ChatMessage(ChatRole.Assistant, "third") { MessageId = "msg3" },
]);

// Act
AgentResponseUpdate[] updates = response.ToAgentResponseUpdates();

// Assert
Assert.Equal(3, updates.Length);
Assert.Equal("msg1", updates[0].MessageId);
Assert.Equal("first", updates[0].Text);
Assert.Equal("msg2", updates[1].MessageId);
Assert.Equal("second", updates[1].Text);
Assert.Equal("msg3", updates[2].MessageId);
Assert.Equal("third", updates[2].Text);
}
}