tests: don't reuse http client as fixture

This commit is contained in:
Stevan Freeborn
2024-06-29 09:49:15 -05:00
parent ffee24d8ec
commit 6caa4b1b06
3 changed files with 9 additions and 15 deletions
@@ -1,9 +1,6 @@
namespace AnthropicClient.Tests.EndToEnd; namespace AnthropicClient.Tests.EndToEnd;
public class ClientTests( public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(configFixture)
HttpClientFixture httpClientFixture,
ConfigurationFixture configFixture
) : EndToEndTest(httpClientFixture, configFixture)
{ {
[Fact] [Fact]
public async Task CreateChatMessage_WhenCalled_ItShouldReturnChatResponse() public async Task CreateChatMessage_WhenCalled_ItShouldReturnChatResponse()
@@ -1,9 +1,6 @@
namespace AnthropicClient.Tests.EndToEnd; namespace AnthropicClient.Tests.EndToEnd;
public class EndToEndTest( public class EndToEndTest(ConfigurationFixture configFixture) : IClassFixture<ConfigurationFixture>
HttpClientFixture httpClientFixture,
ConfigurationFixture configFixture
) : IClassFixture<HttpClientFixture>, IClassFixture<ConfigurationFixture>
{ {
protected readonly AnthropicApiClient _client = new(configFixture.AnthropicApiKey, httpClientFixture.HttpClient); protected readonly AnthropicApiClient _client = new(configFixture.AnthropicApiKey, new());
} }
@@ -6,25 +6,25 @@ public class AnthropicResultTests
public void Success_WhenCalled_ItShouldReturnSuccessResult() public void Success_WhenCalled_ItShouldReturnSuccessResult()
{ {
var value = "success"; var value = "success";
var requestId = Guid.NewGuid().ToString(); var headers = new AnthropicHeaders();
var actual = AnthropicResult<string>.Success(value, requestId); var actual = AnthropicResult<string>.Success(value, headers);
actual.IsSuccess.Should().BeTrue(); actual.IsSuccess.Should().BeTrue();
actual.Value.Should().Be(value); actual.Value.Should().Be(value);
actual.RequestId.Should().Be(requestId); actual.Headers.Should().Be(headers);
} }
[Fact] [Fact]
public void Failure_WhenCalled_ItShouldReturnFailureResult() public void Failure_WhenCalled_ItShouldReturnFailureResult()
{ {
var error = new AnthropicError(new AuthenticationError("message")); var error = new AnthropicError(new AuthenticationError("message"));
var requestId = Guid.NewGuid().ToString(); var headers = new AnthropicHeaders();
var actual = AnthropicResult<string>.Failure(error, requestId); var actual = AnthropicResult<string>.Failure(error, headers);
actual.IsSuccess.Should().BeFalse(); actual.IsSuccess.Should().BeFalse();
actual.Error.Should().Be(error); actual.Error.Should().Be(error);
actual.RequestId.Should().Be(requestId); actual.Headers.Should().Be(headers);
} }
} }