diff --git a/tests/AnthropicClient.Tests/Unit/Models/ToolUseContentTests.cs b/tests/AnthropicClient.Tests/Unit/Models/ToolUseContentTests.cs index 56e55a4..28f3855 100644 --- a/tests/AnthropicClient.Tests/Unit/Models/ToolUseContentTests.cs +++ b/tests/AnthropicClient.Tests/Unit/Models/ToolUseContentTests.cs @@ -22,6 +22,26 @@ public class ToolUseContentTests : SerializationTest actual.Type.Should().Be("tool_use"); } + [Fact] + public void CacheControl_WhenCalledToSetCacheControl_ItShouldSetCacheControl() + { + var id = Guid.NewGuid().ToString(); + var name = "name"; + var input = new Dictionary { { "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] public void JsonSerialization_WhenSerialized_ItShouldReturnJsonString() { @@ -48,6 +68,35 @@ public class ToolUseContentTests : SerializationTest JsonAssert.Equal(expectedJson, actual); } + [Fact] + public void JsonSerialization_WhenSerializedWithCacheControl_ItShouldReturnJsonString() + { + var id = Guid.NewGuid().ToString(); + var name = "name"; + var input = new Dictionary { { "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] public void JsonDeserialization_WhenDeserialized_ItShouldReturnToolUseContent() {