tests: add test to make sure cache control can be set on tool use content objects
This commit is contained in:
@@ -22,6 +22,26 @@ public class ToolUseContentTests : SerializationTest
|
|||||||
actual.Type.Should().Be("tool_use");
|
actual.Type.Should().Be("tool_use");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CacheControl_WhenCalledToSetCacheControl_ItShouldSetCacheControl()
|
||||||
|
{
|
||||||
|
var id = Guid.NewGuid().ToString();
|
||||||
|
var name = "name";
|
||||||
|
var input = new Dictionary<string, object?> { { "name", "input" } };
|
||||||
|
var cacheControl = new EphemeralCacheControl();
|
||||||
|
|
||||||
|
var toolUseContent = new ToolUseContent()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name,
|
||||||
|
Input = input
|
||||||
|
};
|
||||||
|
|
||||||
|
toolUseContent.CacheControl = cacheControl;
|
||||||
|
|
||||||
|
toolUseContent.CacheControl.Should().BeSameAs(cacheControl);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonSerialization_WhenSerialized_ItShouldReturnJsonString()
|
public void JsonSerialization_WhenSerialized_ItShouldReturnJsonString()
|
||||||
{
|
{
|
||||||
@@ -48,6 +68,35 @@ public class ToolUseContentTests : SerializationTest
|
|||||||
JsonAssert.Equal(expectedJson, actual);
|
JsonAssert.Equal(expectedJson, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void JsonSerialization_WhenSerializedWithCacheControl_ItShouldReturnJsonString()
|
||||||
|
{
|
||||||
|
var id = Guid.NewGuid().ToString();
|
||||||
|
var name = "name";
|
||||||
|
var input = new Dictionary<string, object?> { { "name", "input" } };
|
||||||
|
var cacheControl = new EphemeralCacheControl();
|
||||||
|
|
||||||
|
var expectedJson = @$"{{
|
||||||
|
""id"": ""{id}"",
|
||||||
|
""name"": ""{name}"",
|
||||||
|
""input"": {{ ""name"": ""input"" }},
|
||||||
|
""cache_control"": {{ ""type"": ""ephemeral"" }},
|
||||||
|
""type"": ""tool_use""
|
||||||
|
}}";
|
||||||
|
|
||||||
|
var toolUseContent = new ToolUseContent()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Name = name,
|
||||||
|
Input = input,
|
||||||
|
CacheControl = cacheControl
|
||||||
|
};
|
||||||
|
|
||||||
|
var actual = Serialize(toolUseContent);
|
||||||
|
|
||||||
|
JsonAssert.Equal(expectedJson, actual);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonDeserialization_WhenDeserialized_ItShouldReturnToolUseContent()
|
public void JsonDeserialization_WhenDeserialized_ItShouldReturnToolUseContent()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user