Mocking Non-Standard Events in F# Foq

Viewed 264

I'm new to F#, and I'm putting myself through some exercises to learn the language. The one I'm currently trying to do is to write a unit test for a custom Castle.Windsor Facility, and I am trying to Mock the Kernel to raise a "ComponentRegistered" event.

The tools I'm using are FsUnit/xUnit/Foq.

My Code:

let event = Event<_,_>()

let kernel = Mock<IKernel>()
    .SetupEvent(fun k -> <@ k.ComponentRegistered @>)
    .Publishes(event.Publish)
    .Create()

Error Message:

Error 4 The event 'ComponentRegistered' has a non-standard type. If this event is declared in another CLI language, you may need to access this event using the explicit add_ComponentRegistered and remove_ComponentRegistered methods for the event. If this event is declared in F#, make the type of the event an instantiation of either 'IDelegateEvent<>' or 'IEvent<,_>'. C:\Workbench\EvilDev\evildev.commons\Tests\EvilDev.Commons.Windsor.Tests\Auto Resolver Facility Specification.fs 35 53 EvilDev.Commons.Windsor.Tests

How do I mock/trigger this sort of event from F#?

1 Answers
Related