feat: create chat message
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
namespace AnthropicClient.Tests.EndToEnd;
|
||||
|
||||
public class ClientTests(
|
||||
HttpClientFixture httpClientFixture,
|
||||
ConfigurationFixture configFixture
|
||||
) : EndToEndTest(httpClientFixture, configFixture)
|
||||
{
|
||||
[Fact]
|
||||
public async Task CreateChatMessage_WhenCalled_ShouldReturnChatResponse()
|
||||
{
|
||||
var request = new ChatMessageRequest(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
);
|
||||
|
||||
var result = await _client.CreateChatMessageAsync(request);
|
||||
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value.Should().BeOfType<ChatResponse>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace AnthropicClient.Tests.EndToEnd;
|
||||
|
||||
public class ConfigurationFixture
|
||||
{
|
||||
public string AnthropicApiKey { get; }
|
||||
|
||||
public ConfigurationFixture()
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.Test.json")
|
||||
.AddEnvironmentVariables()
|
||||
.Build();
|
||||
|
||||
var anthropicApiKey = configuration["AnthropicApiKey"];
|
||||
|
||||
if (string.IsNullOrEmpty(anthropicApiKey))
|
||||
{
|
||||
throw new InvalidOperationException("AnthropicApiKey is required");
|
||||
}
|
||||
|
||||
AnthropicApiKey = anthropicApiKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace AnthropicClient.Tests.EndToEnd;
|
||||
|
||||
public class EndToEndTest(
|
||||
HttpClientFixture httpClientFixture,
|
||||
ConfigurationFixture configFixture
|
||||
) : IClassFixture<HttpClientFixture>, IClassFixture<ConfigurationFixture>
|
||||
{
|
||||
protected readonly Client _client = new(configFixture.AnthropicApiKey, httpClientFixture.HttpClient);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AnthropicClient.Tests.EndToEnd;
|
||||
|
||||
public class HttpClientFixture
|
||||
{
|
||||
public HttpClient HttpClient { get; }
|
||||
|
||||
public HttpClientFixture()
|
||||
{
|
||||
HttpClient = new HttpClient();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user