feat: add support for file source and url source

This commit is contained in:
Stevan Freeborn
2025-07-14 23:30:02 -05:00
parent 267972ca94
commit 1f83899eb8
10 changed files with 469 additions and 27 deletions
@@ -77,7 +77,7 @@ public class ImageContentTests : SerializationTest
}
[Fact]
public void Constructor_WhenCalledWithCacheControlAndMediatTypeIsNull_ItShouldThrowArgumentNullException()
public void Constructor_WhenCalledWithCacheControlAndMediaTypeIsNull_ItShouldThrowArgumentNullException()
{
var expectedData = "data";
var cacheControl = new EphemeralCacheControl();
@@ -98,6 +98,49 @@ public class ImageContentTests : SerializationTest
action.Should().Throw<ArgumentNullException>();
}
[Fact]
public void Constructor_WhenCalledWithSource_ItShouldInitializeSource()
{
var source = new ImageSource("image/png", "data");
var result = new ImageContent(source);
result.Source.Should().BeSameAs(source);
}
[Fact]
public void Constructor_WhenCalledWithSourceAndCacheControl_ItShouldInitializeSourceAndCacheControl()
{
var source = new ImageSource("image/png", "data");
var cacheControl = new EphemeralCacheControl();
var result = new ImageContent(source, cacheControl);
result.Source.Should().BeSameAs(source);
result.CacheControl.Should().BeSameAs(cacheControl);
}
[Fact]
public void Constructor_WhenSourceIsNull_ItShouldThrowArgumentNullException()
{
Source? source = null;
var action = () => new ImageContent(source!);
action.Should().Throw<ArgumentNullException>();
}
[Fact]
public void Constructor_WhenCacheControlIsNull_ItShouldThrowNullException()
{
var source = new ImageSource("image/png", "data");
CacheControl? cacheControl = null;
var action = () => new ImageContent(source, cacheControl!);
action.Should().Throw<ArgumentNullException>();
}
[Fact]
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
{