tests: add tests for constructor using cache control
This commit is contained in:
@@ -35,6 +35,43 @@ public class ToolResultContentTests : SerializationTest
|
||||
action.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledAndGivenCacheControl_ItShouldInitializeProperties()
|
||||
{
|
||||
var toolUseId = Guid.NewGuid().ToString();
|
||||
var content = "content";
|
||||
var cacheControl = new EphemeralCacheControl();
|
||||
|
||||
var actual = new ToolResultContent(toolUseId, content, cacheControl);
|
||||
|
||||
actual.ToolUseId.Should().Be(toolUseId);
|
||||
actual.Content.Should().Be(content);
|
||||
actual.CacheControl.Should().BeSameAs(cacheControl);
|
||||
actual.Type.Should().Be("tool_result");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledAndGivenCacheControlAndToolUseIdIsNull_ItShouldThrowArgumentNullException()
|
||||
{
|
||||
var content = "content";
|
||||
var cacheControl = new EphemeralCacheControl();
|
||||
|
||||
var action = () => new ToolResultContent(null!, content, cacheControl);
|
||||
|
||||
action.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledAndGivenCacheControlAndContentIsNull_ItShouldThrowArgumentNullException()
|
||||
{
|
||||
var toolUseId = Guid.NewGuid().ToString();
|
||||
var cacheControl = new EphemeralCacheControl();
|
||||
|
||||
var action = () => new ToolResultContent(toolUseId, null!, cacheControl);
|
||||
|
||||
action.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldReturnJsonString()
|
||||
{
|
||||
@@ -58,6 +95,34 @@ public class ToolResultContentTests : SerializationTest
|
||||
JsonAssert.Equal(expectedJson, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerializedWithCacheControl_ItShouldReturnJsonString()
|
||||
{
|
||||
var toolUseId = Guid.NewGuid().ToString();
|
||||
var content = "content";
|
||||
var cacheControl = new EphemeralCacheControl();
|
||||
|
||||
var expectedJson = @$"{{
|
||||
""tool_use_id"": ""{toolUseId}"",
|
||||
""content"": ""{content}"",
|
||||
""type"": ""tool_result"",
|
||||
""cache_control"": {{
|
||||
""type"": ""ephemeral""
|
||||
}}
|
||||
}}";
|
||||
|
||||
var toolResultContent = new ToolResultContent
|
||||
{
|
||||
ToolUseId = toolUseId,
|
||||
Content = content,
|
||||
CacheControl = cacheControl
|
||||
};
|
||||
|
||||
var actual = Serialize(toolResultContent);
|
||||
|
||||
JsonAssert.Equal(expectedJson, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldReturnToolResultContent()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user