According to the documentation of fakeiteasy all I have to do is:
public delegate void CustomEventHandler(object sender, CustomEventArgs e);
event CustomEventHandler CustomEvent;
fake.CustomEvent += Raise.With<CustomEventHandler>(fake, sampleCustomEventArgs);
I tried this in my code as follows:
public delegate void RowStateHandler(object sender, RowStateHandlerArgs e);
public class RowStateHandlerArgs : EventArgs
{
public bool Selected { get; set; }
public string CampaignId { get; set; }
}
... The interface of the view:
public interface ICampaignChannelView
{
event RowStateHandler RowStateChanged;
}
The snippet in my unit test:
ICampaignChannelView v = A.Fake<ICampaignChannelView>();
RowStateHandlerArgs args = new RowStateHandlerArgs() {CampaignId = "1", Selected = true};
v.RowStateChanged += Raise.With<RowStateHandler>(v, args);
I get following compile error:
Error CS0029 Cannot implicitly convert type
FakeItEasy.Raise<Add_in.UI.Wizard.RowStateHandler> to
Add_in.UI.Wizard.RowStateHandler Add-inTests C:\..\WizardPresenterTests.cs
and
Error CS1503 Argument 2: cannot convert from 'Add_in.UI.Wizard.RowStateHandlerArgs' to 'Add_in.UI.Wizard.RowStateHandler' Add-inTests C:..\WizardPresenterTests.cs
Any help is much appreciated!