Skip to content

Commit efd43cf

Browse files
committed
Added test for FileProcessor
1 parent 9940333 commit efd43cf

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.IO;
2+
using System.Threading.Tasks;
3+
using FluentAssertions;
4+
using LinkDotNet.Blog.Web.Shared.Services;
5+
using Microsoft.AspNetCore.Components.Forms;
6+
using Moq;
7+
using Xunit;
8+
9+
namespace LinkDotNet.Blog.UnitTests.Web.Shared.Services;
10+
11+
public class FileProcessorTests
12+
{
13+
[Fact]
14+
public async Task ShouldProcessFileContent()
15+
{
16+
var browserFile = new Mock<IBrowserFile>();
17+
await using var stream = new MemoryStream();
18+
await using var writer = new StreamWriter(stream);
19+
const string streamString = "Hello World";
20+
await writer.WriteAsync(streamString);
21+
await writer.FlushAsync();
22+
stream.Position = 0;
23+
browserFile.Setup(b => b.OpenReadStream(It.IsAny<long>(), default))
24+
.Returns(stream);
25+
26+
var content = await new FileProcessor().GetContent(browserFile.Object);
27+
28+
content.Should().Be(streamString);
29+
}
30+
}

0 commit comments

Comments
 (0)