chore: run dotnet format

This commit is contained in:
Stevan Freeborn
2024-07-01 22:46:02 -05:00
parent f848d4b792
commit 1ae90106b5
21 changed files with 78 additions and 78 deletions
@@ -26,7 +26,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
);
var response = _client.CreateChatMessageAsync(request);
var events = new List<AnthropicEvent>();
await foreach (var e in response)
@@ -46,7 +46,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
);
var response = _client.CreateChatMessageAsync(request);
await foreach (var e in response)
{
if (e.Data is MessageCompleteEventData messageCompleteData)
@@ -1,6 +1,6 @@
namespace AnthropicClient.Tests.Unit.Models;
public class AnthropicResultTests
public class AnthropicResultTests
{
[Fact]
public void Success_WhenCalled_ItShouldReturnSuccessResult()
@@ -35,7 +35,7 @@ public class ChatMessageRequestTests : SerializationTest
""tools"": [],
""stream"":false
}";
private readonly string _testJsonWithSpecificToolChoice = @"{
""model"": ""claude-3-sonnet-20240229"",
""system"": ""test-system"",
@@ -52,7 +52,7 @@ public class ChatMessageRequestTests : SerializationTest
""tools"": [],
""stream"": false
}";
private readonly string _testJsonWithImageContent = @"{
""model"": ""claude-3-sonnet-20240229"",
""system"": ""test-system"",
@@ -77,7 +77,7 @@ public class ChatMessageRequestTests : SerializationTest
""tools"":[],
""stream"": false
}";
private readonly string _testJsonWithUnknownContent = @"{
""model"": ""claude-3-sonnet-20240229"",
""system"": ""test-system"",
@@ -92,7 +92,7 @@ public class ChatMessageRequestTests : SerializationTest
""tools"": [],
""stream"": false
}";
private readonly string _testJsonWithToolUseContent = @"{
""model"": ""claude-3-sonnet-20240229"",
""system"": ""test-system"",
@@ -121,7 +121,7 @@ public class ChatMessageRequestTests : SerializationTest
""tools"": [],
""stream"": false
}";
private readonly string _testJsonWithToolResultContent = @"{
""model"": ""claude-3-sonnet-20240229"",
""system"": ""test-system"",
@@ -369,7 +369,7 @@ public class ChatMessageRequestTests : SerializationTest
specificToolChoice!.Type.Should().Be("tool");
specificToolChoice.Name.Should().Be("test-tool");
chatMessageRequest.Tools.Should().HaveCount(0);
}
}
[Fact]
public void JsonDeserialization_WhenDeserializedWithUnknownToolChoice_ItShouldThrowJsonException()
@@ -6,9 +6,9 @@ public class ContentDeltaTypeTests
public void TextDelta_WhenCalled_ItShouldReturnExpectedValue()
{
var expected = "text_delta";
var actual = ContentDeltaType.TextDelta;
actual.Should().Be(expected);
}
@@ -16,9 +16,9 @@ public class ContentDeltaTypeTests
public void JsonDelta_WhenCalled_ItShouldReturnExpectedValue()
{
var expected = "input_json_delta";
var actual = ContentDeltaType.JsonDelta;
actual.Should().Be(expected);
}
}
@@ -67,11 +67,11 @@ public class ContentStartEventDataTests : SerializationTest
Name = "get_weather",
Input = []
};
var contentStartEventData = new ContentStartEventData(index, toolUseContent);
var actual = Serialize(contentStartEventData);
JsonAssert.Equal(_testJsonWithToolUseBlock, actual);
}
}
}
@@ -6,9 +6,9 @@ public class InvalidRequestErrorTests : SerializationTest
public void Constructor_WhenCalled_ItShouldInitializeProperties()
{
var message = "message";
var error = new InvalidRequestError(message);
error.Type.Should().Be("invalid_request_error");
error.Message.Should().Be(message);
}
@@ -17,11 +17,11 @@ public class InvalidRequestErrorTests : SerializationTest
public void Serialization_WhenSerialized_ItShouldHaveExpectedShape()
{
var message = "message";
var error = new InvalidRequestError(message);
var serialized = Serialize(error);
JsonAssert.Equal(
@"{
""type"": ""invalid_request_error"",
@@ -38,9 +38,9 @@ public class InvalidRequestErrorTests : SerializationTest
""type"": ""invalid_request_error"",
""message"": ""message""
}";
var error = Deserialize<InvalidRequestError>(json);
error!.Type.Should().Be("invalid_request_error");
error.Message.Should().Be("message");
}
@@ -11,9 +11,9 @@ public class TextDeltaTests : SerializationTest
public void Constructor_WhenCalled_ItShouldInitializeProperties()
{
var text = "Hello World!";
var textDelta = new TextDelta(text);
textDelta.Type.Should().Be("text_delta");
textDelta.Text.Should().Be(text);
}
@@ -24,7 +24,7 @@ public class TextDeltaTests : SerializationTest
var textDelta = new TextDelta("Hello World!");
var actual = Serialize(textDelta);
JsonAssert.Equal(_testJson, actual);
}
@@ -135,7 +135,7 @@ public class ToolCallTests : SerializationTest
[Fact]
public async Task InvokeAsync_WhenCalledAndToolHasCustomParameterName_ItShouldReturnSuccessResult()
{
var func = ([FunctionParameter("Person's Age", "Age")]int i) => i.ToString();
var func = ([FunctionParameter("Person's Age", "Age")] int i) => i.ToString();
var anthropicFunction = new AnthropicFunction(func.Method, func.Target);
var tool = new Tool("tool", "description", anthropicFunction);
@@ -212,7 +212,7 @@ public class ToolCallTests : SerializationTest
}";
var input = Deserialize<Dictionary<string, object?>>(personJson);
var toolCall = new ToolCall(tool, new ToolUseContent { Input = input! });
var result = await toolCall.InvokeAsync();
@@ -12,7 +12,7 @@ public class ToolTests : SerializationTest
public void Constructor_WhenGivenInvalidNameValue_ItShouldThrowArgumentException(string name)
{
var method = () => true;
var function = new AnthropicFunction(method.Method);
var function = new AnthropicFunction(method.Method);
var action = () => new Tool(name, "description", function);
action.Should().Throw<ArgumentException>();
@@ -25,7 +25,7 @@ public class ToolTests : SerializationTest
public void Constructor_WhenGivenInvalidDescriptionValue_ItShouldThrowArgumentException(string description)
{
var method = () => true;
var function = new AnthropicFunction(method.Method);
var function = new AnthropicFunction(method.Method);
var action = () => new Tool("name", description, function);
action.Should().Throw<ArgumentException>();
@@ -43,7 +43,7 @@ public class ToolTests : SerializationTest
public void Constructor_WhenCalled_ItShouldInitializeProperties()
{
var method = () => true;
var function = new AnthropicFunction(method.Method);
var function = new AnthropicFunction(method.Method);
var tool = new Tool("test name", "description", function);
var expectedSchema = new JsonObject()
@@ -56,7 +56,7 @@ public class ToolTests : SerializationTest
tool.Description.Should().Be("description");
tool.Function.Should().Be(function);
tool.InputSchema.Should().BeEquivalentTo(
expectedSchema,
expectedSchema,
t => t.IgnoringCyclicReferences()
);
}
@@ -65,7 +65,7 @@ public class ToolTests : SerializationTest
public void Constructor_WhenCalledAndGivenNameIsMoreThanMaxLength_ItShouldTruncateName()
{
var method = () => true;
var function = new AnthropicFunction(method.Method);
var function = new AnthropicFunction(method.Method);
var tool = new Tool(new string('a', 65), "description", function);
tool.Name.Should().HaveLength(64);
@@ -115,7 +115,7 @@ public class ToolTests : SerializationTest
tool.Function.Method.Name.Should().Be(nameof(TestClass.TestStaticMethod));
tool.Function.Instance.Should().BeNull();
tool.InputSchema.Should().BeEquivalentTo(
expectedSchema,
expectedSchema,
t => t.IgnoringCyclicReferences()
);
}
@@ -173,7 +173,7 @@ public class ToolTests : SerializationTest
tool.Function.Method.Name.Should().Be(nameof(TestClass.TestInstanceMethod));
tool.Function.Instance.Should().Be(instance);
tool.InputSchema.Should().BeEquivalentTo(
expectedSchema,
expectedSchema,
t => t.IgnoringCyclicReferences()
);
}
@@ -202,7 +202,7 @@ public class ToolTests : SerializationTest
tool.Description.Should().Be("description");
tool.Function.Method.Should().BeSameAs(func.Method);
tool.InputSchema.Should().BeEquivalentTo(
expectedSchema,
expectedSchema,
t => t.IgnoringCyclicReferences()
);
}
@@ -242,7 +242,7 @@ public class ToolTests : SerializationTest
tool.Description.Should().Be("description");
tool.Function.Method.Should().BeSameAs(func.Method);
tool.InputSchema.Should().BeEquivalentTo(
expectedSchema,
expectedSchema,
t => t.IgnoringCyclicReferences()
);
}
@@ -13,7 +13,7 @@ public class JsonSchemaGeneratorTests
};
var testMethod = () => true;
var function = new AnthropicFunction(testMethod.Method);
var schema = JsonSchemaGenerator.GenerateInputSchema(function);
JsonAssert.Equal(expectedSchema, schema);
@@ -38,7 +38,7 @@ public class JsonSchemaGeneratorTests
var testMethod = (int age = 0) => age;
var function = new AnthropicFunction(testMethod.Method);
var schema = JsonSchemaGenerator.GenerateInputSchema(function);
JsonAssert.Equal(expectedSchema, schema);
@@ -66,7 +66,7 @@ public class JsonSchemaGeneratorTests
var testMethod = (string name) => name;
var function = new AnthropicFunction(testMethod.Method);
var schema = JsonSchemaGenerator.GenerateInputSchema(function);
JsonAssert.Equal(expectedSchema, schema);
+3 -3
View File
@@ -1,9 +1,9 @@
global using FluentAssertions;
global using System.Text.Json;
global using System.Text.Json.JsonDiffPatch.Xunit;
global using AnthropicClient.Models;
global using AnthropicClient.Utils;
global using System.Text.Json;
global using System.Text.Json.JsonDiffPatch.Xunit;
global using FluentAssertions;
global using Microsoft.Extensions.Configuration;