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 TextDeltaTests : SerializationTest
{
private readonly string _testJson = @"{
""type"": ""text_delta"",
""text"": ""Hello World!""
}";
[Fact]
public void Constructor_WhenCalled_ItShouldInitializeProperties()
{
var text = "Hello World!";
var textDelta = new TextDelta(text);
textDelta.Type.Should().Be("text_delta");
textDelta.Text.Should().Be(text);
}
[Fact]
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
{
var textDelta = new TextDelta("Hello World!");
var actual = Serialize(textDelta);
JsonAssert.Equal(_testJson, actual);
}
[Fact]
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedProperties()
{
var expected = new TextDelta("Hello World!");
var actual = Deserialize<TextDelta>(_testJson);
actual.Should().BeEquivalentTo(expected);
}
}