0

I'm trying to test file upload service by pathing IFormFile object but it throws exception when pathing moqed file to target service.

[Fact]
public async Task ReadSheetFile_Test()
{
    var fileMock = new Mock<IFormFile>();
    fileMock.Setup(x => x.FileName).Returns("file1.xlsx");
    var result = _voucherAppService.ReadSheetFile(fileMock.Object);    
    result.Count().ShouldBe(0);
}

Exception

Property accessor 'Location' on object System.Reflection.Emit.InternalAssemblyBuilder threw the following exception:'The invoked member is not supported in a dynamic assembly.

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
  • Does this answer your question? [Loading plug-in DLL files, "The invoked member is not supported in a dynamic assembly."](https://stackoverflow.com/questions/10091221/loading-plug-in-dll-files-the-invoked-member-is-not-supported-in-a-dynamic-ass) – Fabio Jan 04 '21 at 23:55
  • Can we see the implementation of `ReadSheetFile` method? – ema Jan 05 '21 at 08:13

0 Answers0