You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for Blazors <InputFile> component #317
Render a component with the <InputFile> component inside requires additional set up, that bUnit should provide out of the box.
The current solution is to provide a mock of a IOptions<RemoteBrowserFileStreamOptions> and configure the JSInterop to handle the <InputFile> components JSInterop invocation. E.g.
varoptionsMock=Substitute.For<IOptions<RemoteBrowserFileStreamOptions>>();Services.AddSingleton<IOptions<RemoteBrowserFileStreamOptions>>(optionsMock);JSInterop.SetupVoid("Blazor._internal.InputFile.init", x =>true);
This will allow the component to render, but additional steps might be needed to test the "input" part of the component.
To all who are subscribed to that topic: There will be a new nightly build coming out addressing that exact issue. From now on you can use a convenient function to setup InputFile:
// Arrangevarcontext=newTestContext();varcut=context.RenderComponent<MyComponent>();// Arrange the file which gets uploadedvarfileToUpload=InputFileContent.CreateFromText("Hello World","MyFile.txt");// Find the InputFile component and upload the filecut.FindComponent<InputFile>().UploadFiles(fileToUpload);// Assert
Activity
egil commentedon Jun 2, 2021
This discussion post has a complete example for how to test a component that uses the InputFile component: #415
linkdotnet commentedon May 9, 2022
To all who are subscribed to that topic: There will be a new nightly build coming out addressing that exact issue. From now on you can use a convenient function to setup
InputFile: