feat: add DeleteMessageBatchAsync method and MessageBatchDeleteResponse model with tests
This commit is contained in:
@@ -1904,4 +1904,28 @@ public class AnthropicApiClientTests : IntegrationTest
|
||||
result.Error.Should().BeOfType<AnthropicError>();
|
||||
result.Error.Error.Should().BeOfType<InvalidRequestError>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DeleteMessageBatchAsync_WhenCalled_ItShouldReturnDeletionResponse()
|
||||
{
|
||||
var batchId = "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF";
|
||||
|
||||
_mockHttpMessageHandler
|
||||
.WhenDeleteMessageBatchRequest(batchId)
|
||||
.Respond(
|
||||
HttpStatusCode.OK,
|
||||
"application/json",
|
||||
@"{
|
||||
""id"": ""msgbatch_013Zva2CMHLNnXjNJJKqJ2EF"",
|
||||
""type"": ""message_batch_deleted""
|
||||
}"
|
||||
);
|
||||
|
||||
var result = await Client.DeleteMessageBatchAsync(batchId);
|
||||
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value.Should().BeOfType<MessageBatchDeleteResponse>();
|
||||
result.Value.Id.Should().Be(batchId);
|
||||
result.Value.Type.Should().Be("message_batch_deleted");
|
||||
}
|
||||
}
|
||||
@@ -97,4 +97,10 @@ public static class MockHttpMessageHandlerExtensions
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Post, $"{MessageBatchesEndpoint}/{batchId}/cancel");
|
||||
}
|
||||
|
||||
public static MockedRequest WhenDeleteMessageBatchRequest(this MockHttpMessageHandler mockHttpMessageHandler, string batchId)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Delete, $"{MessageBatchesEndpoint}/{batchId}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchDeleteResponseTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""id"": ""test-id"",
|
||||
""type"": ""test-type""
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new MessageBatchDeleteResponse();
|
||||
|
||||
result.Id.Should().BeEmpty();
|
||||
result.Type.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var result = new MessageBatchDeleteResponse
|
||||
{
|
||||
Id = "test-id",
|
||||
Type = "test-type"
|
||||
};
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedValues()
|
||||
{
|
||||
var result = Deserialize<MessageBatchDeleteResponse>(SampleJson);
|
||||
|
||||
result!.Id.Should().Be("test-id");
|
||||
result.Type.Should().Be("test-type");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user