In Development
Last Updated: 26 Jun 2024 07:39 by ADMIN

Having the simple class

public class MyClass
{
    public event Func<EventArgs, Task>? MyEventAsync;
}
and the test that tries to rise the declared event
[TestMethod]
public void TestMethod1()
{
    var mockClass = Mock.Create<MyClass>(Behavior.Strict);
    mockClass.MyEventAsync += (args) => Task.CompletedTask;

    Mock.Raise(() => mockClass.MyEventAsync += null, EventArgs.Empty);
}

Execution triggers 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)

which is kind of unexpected since the supplied arguments are matching to the event's signature.