Skip to content

Commit ba251d3

Browse files
committed
Assert that reading image from local baseImageUrl works
1 parent 3bdee30 commit ba251d3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/HtmlToOpenXml.Tests/ImgTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,22 @@ public void ManualProvisioning_WithNoContent_ShouldBeIgnored()
8080
Assert.That(elements, Is.Empty);
8181
}
8282

83+
[Test(Description = "Reading image from a local base image url.")]
84+
public async Task FileSystem_LocalImage_WithBaseUri_ShouldSucceed()
85+
{
86+
string baseUri = TestContext.CurrentContext.WorkDirectory;
87+
88+
using var resourceStream = ResourceHelper.GetStream("Resources.html2openxml.jpg");
89+
using (var fileStream = File.OpenWrite(Path.Combine(baseUri, "html2openxml.jpg")))
90+
await resourceStream.CopyToAsync(fileStream);
91+
92+
converter = new(mainPart, new IO.DefaultWebRequest { BaseImageUrl = new Uri(baseUri) });
93+
94+
var elements = await converter.ParseAsync("<img src='html2openxml.jpg'>");
95+
Assert.That(elements.Count(), Is.EqualTo(1));
96+
AssertIsImg(mainPart, elements.First());
97+
}
98+
8399
[Test(Description = "Reading local file containing a space in the name")]
84100
public async Task FileSystem_LocalImage_WithSpaceInName_ShouldSucceed()
85101
{

0 commit comments

Comments
 (0)