tests: work on adding integration tests
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
namespace AnthropicClient.Tests.Integration;
|
||||
|
||||
public class AnthropicApiClientTests : IntegrationTest
|
||||
{
|
||||
[Theory]
|
||||
[ClassData(typeof(ErrorTestData))]
|
||||
public async Task CreateChatMessageAsync_WhenCalledAndErrorReturned_ItShouldHandleError(
|
||||
HttpStatusCode statusCode,
|
||||
string content,
|
||||
Type errorType
|
||||
)
|
||||
{
|
||||
_mockHttpMessageHandler
|
||||
.WhenCreateMessageRequest()
|
||||
.Respond(
|
||||
statusCode,
|
||||
"application/json",
|
||||
content
|
||||
);
|
||||
|
||||
var request = new ChatMessageRequest(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
);
|
||||
|
||||
var result = await Client.CreateChatMessageAsync(request);
|
||||
|
||||
result.IsSuccess.Should().BeFalse();
|
||||
result.Error.Should().BeOfType<AnthropicError>();
|
||||
|
||||
var actualErrorType = result.Error.Error!.GetType();
|
||||
actualErrorType.Should().Be(errorType);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user