I am using InputFile in Blazor to accept csv files from user.
While doing testing I want to either give a physical file to InputFile or I want to mock a CSV file and do the testing.
I created a mock as below but I don't know how to give Name,mock data(in file) to this mock:
var mockIbrowser = new Mock<IReadOnlyList<IBrowserFile>>();
Actual Test Case:
[Fact]
public void FileUploadTest()
{
using var ctx = new TestContext();
var mockIbrowser = new Mock<IReadOnlyList<IBrowserFile>>();
var optionsMock = Substitute.For<IOptions<RemoteBrowserFileStreamOptions>>();
ctx.Services.AddSingleton<IOptions<RemoteBrowserFileStreamOptions>>(optionsMock);
ctx.JSInterop.SetupVoid("Blazor._internal.InputFile.init", x => true);
//Arrange
var comp = ctx.RenderComponent<FileProcess>();
//expected
string expectedMarkupButton = @"<button type=""submit"" class=""btn btn-outline-primary"" @btnstatus>Upload Selected File(s)</button>";
string expectedMarkupMsg = @"<h3 style=""color:Black;"">All Tasks performed successfully</h3>";
//Action
comp.Find("InputFile").Click();
comp.Find("form").Submit();
//Matched ?
comp.Find("button").MarkupMatches(expectedMarkupButton);
comp.Find("h3").MarkupMatches(expectedMarkupMsg);
}