Skip to content

Commit dbc92f8

Browse files
authored
Fix GenerateImagesAsync_SingleImageGeneration integration test (#6843)
Both DataContent and UriContent are valid in responses, and from both OpenAI and Azure OpenAI, I get back a UriContent.
1 parent ecfdb53 commit dbc92f8

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test/Libraries/Microsoft.Extensions.AI.Integration.Tests/ImageGeneratorIntegrationTests.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,23 @@ public virtual async Task GenerateImagesAsync_SingleImageGeneration()
4343

4444
Assert.NotNull(response);
4545
Assert.NotEmpty(response.Contents);
46-
Assert.Single(response.Contents);
4746

48-
var content = response.Contents[0];
49-
Assert.IsType<DataContent>(content);
50-
var dataContent = (DataContent)content;
51-
Assert.False(dataContent.Data.IsEmpty);
52-
Assert.StartsWith("image/", dataContent.MediaType, StringComparison.Ordinal);
47+
var content = Assert.Single(response.Contents);
48+
switch (content)
49+
{
50+
case UriContent uc:
51+
Assert.StartsWith("http", uc.Uri.Scheme, StringComparison.Ordinal);
52+
break;
53+
54+
case DataContent dc:
55+
Assert.False(dc.Data.IsEmpty);
56+
Assert.StartsWith("image/", dc.MediaType, StringComparison.Ordinal);
57+
break;
58+
59+
default:
60+
Assert.Fail($"Unexpected content type: {content.GetType()}");
61+
break;
62+
}
5363
}
5464

5565
[ConditionalFact]

0 commit comments

Comments
 (0)