Question

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".

Was it helpful?

Solution 2

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.

OTHER TIPS

Answer is Event.ADDED_TO_STAGE is fired before mediator is registered.

When ever you view added to stage that time only your mediator class registered.

view.addEventListener( Event.ADDED_TO_STAGE , addedToStageHandler );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top