Testing event handlers in XUnit can be done through the Assert.Raises method. This method expect 3 parameters:
- An action of EventHandler<T> to attach a handler
- An action of EventHandler<T> to detach the handler
- An action containing the code that should trigger the event
This was not immediately clear to me so here is a (simple) example:
And here is the interface of the IUnitOfWork that is tested above: