I wrote the following test for my PureMVC project
[Test]
public function facadeCanRegisterMediator():void {
if(!Facade.getInstance().hasMediator(NewReelMediator.NAME)) {
Facade.getInstance().registerMediator(new NewReelMediator());
}
assertTrue(Facade.getInstance().hasMediator(NewReelMediator.NAME));
}
However it is always failing. What event do I need to be listening for before I check that the facade has the mediator? Or is there some other reason it is failing?
I get the message "expected true but was false".
Well I feel stupid!
The answer to my question is that I left out the name of the Mediator when registering it!
The proper code should be:
[Test]
public function facadeCanRegisterMediator():void {
if(!Facade.getInstance().hasMediator(NewReelMediator.NAME)) {
Facade.getInstance().registerMediator(new NewReelMediator(NewReelMediator.NAME));
}
assertTrue(Facade.getInstance().hasMediator(NewReelMediator.NAME));
}
which of course... passes. Events have nothing to do with it. There is no event which is fired when a mediator is registered.