I write code contracts on an interface that uses events:
interface EventInterface<T> {
event EventHandler ItemAdded;
bool Add(T item);
}
When an item is added to a collection that implements the interface, the collection should raise an event ItemAdded. An event should only be raised if an item has been added; this is set by the return value (think of a set, where it truemeans that the element was added, falsemeans that it was not added, because it already exists in the set).
I want to have a contract that ensures that if the result is correct, the event will be raised. Similarly, if the result is false, the event is not raised. Is there any way to verify that using contracts?
source
share