tests: cover null responses

This commit is contained in:
Stevan Freeborn
2025-01-12 13:26:31 -06:00
parent 299af3b759
commit 876c6f571c
10 changed files with 370 additions and 17 deletions
@@ -0,0 +1,25 @@
namespace AnthropicClient.Tests.Unit.Models;
public class MessageBatchResultTests : SerializationTest
{
[Fact]
public void JsonDeserialization_WhenHasUnknownType_ItShouldThrowException()
{
var json = @"{""type"":""unknown""}";
var action = () => Deserialize<MessageBatchResult>(json);
action.Should().Throw<JsonException>();
}
[Fact]
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
{
var expectedJson = @"{""type"":""expired""}";
var messageBatchResult = new ExpiredMessageBatchResult();
var json = Serialize<MessageBatchResult>(messageBatchResult);
JsonAssert.Equal(expectedJson, json);
}
}