For the sake of brevity, I've included a minimal example below. An async event MyEventAsync is defined in class MyClass. An event handler OnMyEventAsync is also defined.
public class MyClass
{
// Event.
public event Func<EventArgs, Task>? MyEventAsync;
}
// Event handler.
private Task OnMyEventAsync(EventArgs args) => Task.CompletedTask;
I then create a mock of MyClass and register the event handler OnMyEventAsync with the event MyEventAsync. Then Raise the event with the syntax given in the documentation.
// Create mock.
var mockClass = Mock.Create<MyClass>(Behavior.Strict);
// Register event handler.
mockClass.MyEventAsync += OnMyEventAsync;
// Raise event on mock.
Mock.Raise(() => mockClass.MyEventAsync += null, EventArgs.Empty);
But I receive the following error:
Telerik.JustMock.Core.MockException : Event signature System.Threading.Tasks.Task OnMyEventAsync(System.EventArgs) is incompatible with argument types (Castle.Proxies.ExternalMockMixinProxy, System.EventArgs)
I've probably missed something very obvious here. I know the above syntax should work with an event of type EventHandler<EventArgs>, but I'm not sure how to modify it to work with event of type Func<EventArgs, Task>. If anyone could clear up my confusion, I'd be most grateful. Thanks! =)