tests: add additional test coverage
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user