Open xosmig opened 2 years ago
Does this apply only to ActiveModule
s, or are PassiveModule
s (which are defined only in terms of function calls and return values) also problematic?
In fact, I just realized that there is a simple work-around for passive modules :sweat_smile:
The problem with passive modules is the built-in batching: we have to set expectations on ApplyEvents
, which may contain several events at once.
The work-around is to create an interface with the method ApplyEvent
instead of ApplyEvents
and mock this interface instead of PassiveModule
itself.
Then we can wrap the mocked object in order to implement the PassiveModule
interface.
Not sure if this solution will be as good as first-class mocking utilities for Mir, but it is probably good enough for now.
Standard mocking utils like gomock do not really work well with Mir because they only allow setting expectations on method calls while we need to set expectations on the received events and, instead of specifying return values, we should be able to specify output events.