tests: add missing tests for streaming chat message

This commit is contained in:
Stevan Freeborn
2024-06-29 22:07:49 -05:00
parent 77ceb49c77
commit 5edc0b5fff
16 changed files with 1183 additions and 7 deletions
@@ -0,0 +1,40 @@
namespace AnthropicClient.Tests.Unit.Models;
public class JsonDeltaTests : SerializationTest
{
private readonly string _testJson = @"{
""type"": ""input_json_delta"",
""partial_json"": ""{\""key\"": \""value\""}""
}";
[Fact]
public void Constructor_WhenCalled_ItShouldInitializeProperties()
{
var partialJson = "{\"key\": \"value\"}";
var jsonDelta = new JsonDelta(partialJson);
jsonDelta.Type.Should().Be("input_json_delta");
jsonDelta.PartialJson.Should().Be(partialJson);
}
[Fact]
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
{
var jsonDelta = new JsonDelta("{\"key\": \"value\"}");
var actual = Serialize(jsonDelta);
JsonAssert.Equal(_testJson, actual);
}
[Fact]
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedProperties()
{
var expected = new JsonDelta("{\"key\": \"value\"}");
var actual = Deserialize<JsonDelta>(_testJson);
actual.Should().BeEquivalentTo(expected);
}
}