I am learning robotlegs framework, but this question is also I think of general nature.
I have a Mediator class that listens for event on a button in View and on that event it dispatches a signal containing VO which contains properities from two TextField objects in View.
Below is mediator class.
button is a private variable that only has getter and no setter in View.
My Question is, how would I unit test this class? 1. to check if event comes that Signal is being dispatched... 2. when signal is dispatched, that it contains correct VO
I know that I need to use Mock, and I am using mockolate, but i am spinning in circle, because i don't know how to mock a dispatched event from a button from view class?
Thanks for help
public class LoginFormMediator extends Mediator {
//---------------------------------------------------------------
// Public variables
//---------------------------------------------------------------
[Inject]
public var view:LoginFormView;
[Inject]
public var authorizationSignal:AuthorizationSignal;
//---------------------------------------------------------------
// Public Functions
//---------------------------------------------------------------
override public function initialize():void
{
view.button.addEventListener(MouseEvent.CLICK,onLogin,false,0,true);
}
//---------------------------------------------------------------
// Private methods
//---------------------------------------------------------------
private function onLogin(event:MouseEvent):void {
var userInfo:UserInfo = new UserInfo(view.usernameField.text,view.passwordField.text);
authorizationSignal.dispatch(userInfo);
}
}
}