tests: add additional test coverage

This commit is contained in:
Stevan Freeborn
2025-07-08 21:56:13 -05:00
parent 598eaaad94
commit 2732ae2b21
7 changed files with 198 additions and 10 deletions
@@ -1,7 +1,17 @@
namespace AnthropicClient.Tests.Unit.Models;
public class CustomSourceTests
public class CustomSourceTests : SerializationTest
{
private readonly string _testJson = @"{
""type"": ""content"",
""content"": [
{
""type"": ""text"",
""text"": ""Sample text""
}
]
}";
[Fact]
public void Constructor_WhenCalled_ItShouldSetProperties()
{
@@ -32,4 +42,30 @@ public class CustomSourceTests
act.Should().Throw<ArgumentNullException>();
}
[Fact]
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
{
var content = new List<TextContent>
{
new("Sample text")
};
var source = new CustomSource(content);
var result = Serialize<Source>(source);
JsonAssert.Equal(_testJson, result);
}
[Fact]
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedShape()
{
var source = Deserialize<Source>(_testJson);
var customSource = source.As<CustomSource>();
customSource!.Type.Should().Be("content");
customSource.Content.Should().HaveCount(1);
customSource.Content[0].Type.Should().Be("text");
customSource.Content[0].Text.Should().Be("Sample text");
}
}