From 914495ab975c6bfe89a1c7e9f45d321d4c626b50 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:49:28 -0500 Subject: [PATCH] tests: add create file request tests --- .../Unit/Models/CreateFileRequestTests.cs | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/tests/AnthropicClient.Tests/Unit/Models/CreateFileRequestTests.cs b/tests/AnthropicClient.Tests/Unit/Models/CreateFileRequestTests.cs index e69de29..0b749dd 100644 --- a/tests/AnthropicClient.Tests/Unit/Models/CreateFileRequestTests.cs +++ b/tests/AnthropicClient.Tests/Unit/Models/CreateFileRequestTests.cs @@ -0,0 +1,106 @@ +namespace AnthropicClient.Tests.Unit.Models; + +public class CreateFileRequestTests +{ + [Fact] + public void Constructor_WhenCalledWithBytes_ItShouldInitializeProperties() + { + var fileContent = new byte[] { 1, 2, 3 }; + var fileName = "test.txt"; + var fileType = "text/plain"; + + var request = new CreateFileRequest(fileContent, fileName, fileType); + + request.File.Should().BeSameAs(fileContent); + request.FileName.Should().Be(fileName); + request.FileType.Should().Be(fileType); + } + + [Fact] + public void Constructor_WhenCalledWithStream_ItShouldInitializeProperties() + { + using var stream = new MemoryStream([1, 2, 3]); + var fileName = "test.txt"; + var fileType = "text/plain"; + + var request = new CreateFileRequest(stream, fileName, fileType); + + request.File.Should().BeEquivalentTo(new byte[] { 1, 2, 3 }); + request.FileName.Should().Be(fileName); + request.FileType.Should().Be(fileType); + } + + [Fact] + public void Constructor_WhenCalledWithNullBytes_ItShouldThrowArgumentNullException() + { + var act = () => new CreateFileRequest((byte[])null!, "test.txt", "text/plain"); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithBytesAndNullFileName_ItShouldThrowArgumentException() + { + var act = () => new CreateFileRequest([1, 2, 3], null!, "text/plain"); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithBytesAndFileNameIsEmpty_ItShouldThrowArgumentException() + { + var act = () => new CreateFileRequest([1, 2, 3], string.Empty, "text/plain"); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithBytesAndNullFileType_ItShouldThrowArgumentException() + { + var act = () => new CreateFileRequest([1, 2, 3], "test.txt", null!); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithBytesAndFileTypeIsEmpty_ItShouldThrowArgumentException() + { + var act = () => new CreateFileRequest([1, 2, 3], "test.txt", string.Empty); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithNullStream_ItShouldThrowArgumentNullException() + { + var act = () => new CreateFileRequest((Stream)null!, "test.txt", "text/plain"); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithStreamAndNullFileName_ItShouldThrowArgumentException() + { + using var stream = new MemoryStream([1, 2, 3]); + var act = () => new CreateFileRequest(stream, null!, "text/plain"); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithStreamAndFileNameIsEmpty_ItShouldThrowArgumentException() + { + using var stream = new MemoryStream([1, 2, 3]); + var act = () => new CreateFileRequest(stream, string.Empty, "text/plain"); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithStreamAndNullFileType_ItShouldThrowArgumentException() + { + using var stream = new MemoryStream([1, 2, 3]); + var act = () => new CreateFileRequest(stream, "test.txt", null!); + act.Should().Throw(); + } + + [Fact] + public void Constructor_WhenCalledWithStreamAndFileTypeIsEmpty_ItShouldThrowArgumentException() + { + using var stream = new MemoryStream([1, 2, 3]); + var act = () => new CreateFileRequest(stream, "test.txt", string.Empty); + act.Should().Throw(); + } +} \ No newline at end of file