fix: add missing type property to image source model
This commit is contained in:
@@ -20,6 +20,11 @@ public class ImageSource
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Data { get; init; } = string.Empty;
|
public string Data { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of encoding of the image data.
|
||||||
|
/// </summary>
|
||||||
|
public string Type { get; init; } = "base64";
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
internal ImageSource()
|
internal ImageSource()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<IsTestProject>true</IsTestProject>
|
<IsTestProject>true</IsTestProject>
|
||||||
|
<NoWarn>$(NoWarn);IDE0039</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
namespace AnthropicClient.Tests.Unit.Models;
|
||||||
|
|
||||||
|
public class ImageSourceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithValidArguments_ItShouldSetProperties()
|
||||||
|
{
|
||||||
|
var mediaType = "image/jpeg";
|
||||||
|
var data = "base64data";
|
||||||
|
|
||||||
|
var imageSource = new ImageSource(mediaType, data);
|
||||||
|
|
||||||
|
imageSource.MediaType.Should().Be(mediaType);
|
||||||
|
imageSource.Data.Should().Be(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithInvalidMediaType_ItShouldThrowArgumentException()
|
||||||
|
{
|
||||||
|
var mediaType = "invalid";
|
||||||
|
var data = "base64data";
|
||||||
|
|
||||||
|
var action = () => new ImageSource(mediaType, data);
|
||||||
|
|
||||||
|
action.Should().Throw<ArgumentException>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithNullMediaType_ItShouldThrowArgumentNullException()
|
||||||
|
{
|
||||||
|
string? mediaType = null;
|
||||||
|
var data = "base64data";
|
||||||
|
|
||||||
|
var action = () => new ImageSource(mediaType!, data);
|
||||||
|
|
||||||
|
action.Should().Throw<ArgumentNullException>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalledWithNullData_ItShouldThrowArgumentNullException()
|
||||||
|
{
|
||||||
|
var mediaType = "image/jpeg";
|
||||||
|
string? data = null;
|
||||||
|
|
||||||
|
var action = () => new ImageSource(mediaType, data!);
|
||||||
|
|
||||||
|
action.Should().Throw<ArgumentNullException>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_WhenCalled_ItShouldHaveTypePropertySetToBase64()
|
||||||
|
{
|
||||||
|
var mediaType = "image/jpeg";
|
||||||
|
var data = "base64data";
|
||||||
|
|
||||||
|
var imageSource = new ImageSource(mediaType, data);
|
||||||
|
|
||||||
|
imageSource.Type.Should().Be("base64");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user