chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male

Can you please provide the solution for query, how to mock crystal report method ?

+2 votes

How to mock the GenerateReport() of CrystalReportsColdReportHack class. While mocking this method I am getting key not found in dictionary but if I mock and pass null as parameter in method its working.

 public static MemoryStream GenerateReport<T>(Func<ReportDocument, MemoryStream> execute)
How to mock and what parameter I need to pass for the above method?
Can you pllease suggest how to implement?
asked Nov 14, 2017 by SujayaK (6,130 points)

1 Answer

0 votes

Hey sujayaK,

When you got the "key not found in dictionary" error, how did you mock the method?

Mocking the method with null parameter should work fine. It will mock the method when it's called with any argument. 

If you want to mock it only for specific arguments, you can use "WithExactArguments".

answered Nov 14, 2017 by SapirTypemock (2,470 points)
Hey sujayaK,

Did you manage to resolve this issue?