tests: work on adding integration tests
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
namespace AnthropicClient.Tests.Integration;
|
||||
|
||||
public class IntegrationTest
|
||||
{
|
||||
protected readonly MockHttpMessageHandler _mockHttpMessageHandler = new();
|
||||
protected AnthropicApiClient Client => CreateClient();
|
||||
|
||||
private AnthropicApiClient CreateClient()
|
||||
{
|
||||
return new AnthropicApiClient("test-key", _mockHttpMessageHandler.ToHttpClient());
|
||||
}
|
||||
}
|
||||
|
||||
public static class MockHttpMessageHandlerExtensions
|
||||
{
|
||||
private static MockedRequest SetupBaseRequest(this MockHttpMessageHandler mockHttpMessageHandler)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.When(HttpMethod.Post, "https://api.anthropic.com/v1/messages")
|
||||
.WithHeaders(new Dictionary<string, string>
|
||||
{
|
||||
{ "anthropic-version", "2023-06-01" },
|
||||
{ "x-api-key", "test-key" }
|
||||
});
|
||||
}
|
||||
|
||||
public static MockedRequest WhenCreateMessageRequest(this MockHttpMessageHandler mockHttpMessageHandler)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest()
|
||||
.WithJsonContent<ChatMessageRequest>(r => r.Stream == false);
|
||||
}
|
||||
|
||||
public static MockedRequest WhenCreateStreamMessageRequest(this MockHttpMessageHandler mockHttpMessageHandler)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest()
|
||||
.WithJsonContent<ChatMessageRequest>(r => r.Stream == true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user