Created
January 15, 2011 14:45
-
-
Save weyert/780950 to your computer and use it in GitHub Desktop.
Mock class for iModuleDelegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MockModuleDelegate implements IModuleDelegate { | |
public function getTranslation( name: String, defaultValue: String = "" ): String { | |
if ( name == "title" ) { | |
return "Moduel Title"; | |
} else if ( name = "currency" ) { | |
return "EUR"; | |
} | |
// more resource strings here | |
} | |
public function getCacheItem( name: String ): Object { return null } | |
public function getAvailableCacheItems( name: String ): Array { return ["data1", "data2] } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mockolateMaker:IEventDispatcher = prepare(IModuleDelegate); | |
mockolateMaker.addEventListener(Event.COMPLETE, prepareCompleteHandler); | |
private function prepareCompleteHandler(e:Event):void{ | |
IEventDispatcher(e.target).removeEventListener(Event.COMPLETE, prepareCompleteHandler); | |
var moduleDelegate: IModuleDelegate = nice(IModuleDelegate); | |
mock(moduleDelegate).method("getTranslation").args("title").returns("Module Title"); | |
mock(moduleDelegate).method("getTranslation").args("currency").returns("EUR"); | |
trace("Forcing module delegate for the application"); | |
this.delegate = moduleDelegate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment