Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can "event Action<>" be invoked with 3 type arguments using fakeiteasy in unit tests

I have looked quite a lot on the internet but somehow I am not grasping the concept to solve my problem. It should not be that complicated.

I have a SUT (System Under Test), which has an event action like:

    event Action<ISomeInterface, bool, string> DownloadFinished;

Now i want to raise this event using the fake object (using fakeiteasy), like:

fakeObject.DownloadFinished  = Raise.With<ISomeInterface, bool, string>();

but the above line shows error as it says "Raise cannot take 3 arguments". Could someone recommend how to solve this issue.

like image 584
Newbie007 Avatar asked Dec 17 '25 20:12

Newbie007


1 Answers

According to my reading of the docs, if you're using a non-EventHandler event, you need to use Raise.FreeForm.With:

fakeObject.DownloadFinished += Raise.FreeForm.With(implementerOfSomeInterface, false, string.Empty);

or similar

like image 132
AakashM Avatar answered Dec 20 '25 11:12

AakashM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!