Is it possible to ask Mockolate to dispatch binding events?
For example, given this class:
class Person {
[Bindable]
public var name:String;
}
I'd like the mock:
var mockPerson:Person = nice(Person);
To dispatch a propertyChangeEvent
when the name
field is change.
As you mentioned Binding events are instances of PropertyChangeEvent
, just create an instance using PropertyChangeEvent.createUpdateEvent()
and use that with .dispatches()
.
Like so:
mock(person).setter("name").arg(anything())
.dispatches(PropertyChangeEvent.createUpdateEvent(person, "name", oldValue, newValue));
Note however that the oldValue
and newValue
will need to be supplied.
I see merit in making a shortcut for this scenario seeing as binding is heavily used. The only tricky part is keeping the previous value.
If you wanted to tackle implementing this yourself I suggest looking at the Answer
and Decorator
classes and subclasses.