Hi,
I am trying to setup a unit test around a component that involves a <TelerikFileSelect>
<TelerikFileSelect
Id="fileSelect"
AllowedExtensions="@AllowedExtensions"
MaxFileSize="@MaxFileSize"
OnSelect="@ImportHandler"
Multiple="false"
DropZoneId="dz"
OnRemove="@ImportRemove"
@ref="FileSelectRef">
<SelectFilesButtonTemplate>
<i class="fas fa-upload"></i>
Upload Excel Spreadsheet
</SelectFilesButtonTemplate>
</TelerikFileSelect>
I am not sure how to setup the `FileSelectEventArgs` in order to test our response to the uploaded file
var fileSelect = myComponent.FindComponent<TelerikFileSelect>();
await myComponent.InvokeAsync(async () => await fileSelect.Instance.OnSelect.InvokeAsync(new FileSelectEventArgs
{
Files = new List<FileSelectFileInfo>(new []{new FileSelectFileInfo
{
Id = null,
Name = null,
Size = 0,
Extension = null,
InvalidExtension = false,
InvalidMinFileSize = false,
InvalidMaxFileSize = false,
Stream = null
}
}),
IsCancelled = false
}));
It seems like 'Stream' is expecting a 'FileInfoStream' which in turn is expecting a 'FileSelectFileInfo', which is expecting a 'FileInfoStream' and so onNot sure if it matters but I am using ClosedXML to generate a memory stream that contains the excel file, so just want to pass that to the TelerikFileSelect
public MemoryStream MockImportExcelFile_HappyPath()
{
var workbook = new XLWorkbook();
var ws = workbook.Worksheets.Add("Sheet 1");
ws.Cell("A1").Value = "Header1";
ws.Cell("A2").Value = "asdfasdf";
var stream = new MemoryStream();
workbook.SaveAs(stream);
stream.Seek(0, SeekOrigin.Begin);
return stream;
}