feat: add unit tests for DocumentContent, CustomSource, PageLocationCitation, SourceType, and TextSource classes
chore: update VSCode settings to exclude docs from search
This commit is contained in:
Vendored
+4
-1
@@ -17,5 +17,8 @@
|
|||||||
"targetdir",
|
"targetdir",
|
||||||
"typeof"
|
"typeof"
|
||||||
],
|
],
|
||||||
"dotnet.unitTests.runSettingsPath": "./tests/AnthropicClient.Tests/.runsettings"
|
"dotnet.unitTests.runSettingsPath": "./tests/AnthropicClient.Tests/.runsettings",
|
||||||
|
"search.exclude": {
|
||||||
|
"**/docs": true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
namespace AnthropicClient.Tests.Unit.Models;
|
||||||
|
|
||||||
|
public class CustomSourceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalled_ItShouldSetProperties()
|
||||||
|
{
|
||||||
|
var result = new CustomSource();
|
||||||
|
|
||||||
|
result.Content.Should().BeEmpty();
|
||||||
|
result.Type.Should().Be("content");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithContent_ItShouldSetProperties()
|
||||||
|
{
|
||||||
|
var content = new List<TextContent>
|
||||||
|
{
|
||||||
|
new("Sample text")
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = new CustomSource(content);
|
||||||
|
|
||||||
|
result.Content.Should().BeSameAs(content);
|
||||||
|
result.Type.Should().Be("content");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithNullContent_ItShouldThrowArgumentNullException()
|
||||||
|
{
|
||||||
|
var act = () => new CustomSource(null!);
|
||||||
|
|
||||||
|
act.Should().Throw<ArgumentNullException>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,6 +87,18 @@ public class DocumentContentTests : SerializationTest
|
|||||||
action.Should().Throw<ArgumentNullException>();
|
action.Should().Throw<ArgumentNullException>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithSourceAndCacheControl_ItShouldInitializeSourceAndCacheControl()
|
||||||
|
{
|
||||||
|
var source = new DocumentSource("application/pdf", "data");
|
||||||
|
var cacheControl = new EphemeralCacheControl();
|
||||||
|
|
||||||
|
var result = new DocumentContent(source, cacheControl);
|
||||||
|
|
||||||
|
result.Source.Should().BeSameAs(source);
|
||||||
|
result.CacheControl.Should().BeSameAs(cacheControl);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace AnthropicClient.Tests.Unit.Models;
|
||||||
|
|
||||||
|
public class PageLocationCitationTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalled_ItShouldSetProperties()
|
||||||
|
{
|
||||||
|
var result = new PageLocationCitation();
|
||||||
|
|
||||||
|
result.Type.Should().Be("page_location");
|
||||||
|
result.CitedText.Should().BeEmpty();
|
||||||
|
result.DocumentIndex.Should().Be(0);
|
||||||
|
result.DocumentTitle.Should().BeEmpty();
|
||||||
|
result.StartPageNumber.Should().Be(0);
|
||||||
|
result.EndPageNumber.Should().Be(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
namespace AnthropicClient.Tests.Unit.Models;
|
||||||
|
|
||||||
|
public class SourceTypeTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Base64_WhenCalled_ItShouldReturnCorrectValue()
|
||||||
|
{
|
||||||
|
SourceType.Base64.Should().Be("base64");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Content_WhenCalled_ItShouldReturnCorrectValue()
|
||||||
|
{
|
||||||
|
SourceType.Content.Should().Be("content");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Text_WhenCalled_ItShouldReturnCorrectValue()
|
||||||
|
{
|
||||||
|
SourceType.Text.Should().Be("text");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace AnthropicClient.Tests.Unit.Models;
|
||||||
|
|
||||||
|
public class TextSourceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalled_ItShouldSetProperties()
|
||||||
|
{
|
||||||
|
var result = new TextSource("data");
|
||||||
|
|
||||||
|
result.Type.Should().Be("text");
|
||||||
|
result.MediaType.Should().Be("text/plain");
|
||||||
|
result.Data.Should().Be("data");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user