Testing Async service that uses callbacks, not Events
Hello All,
I am curios how others are writing Async tests on a service layer where events are not used?
Ex: calling into a service object - sending a callback method (closure)
####
private function buyItem(id:String, callback:Function
{
DataManager.getInstance().purchaseItem(id, callback);
}
private function callback(success:Boolean, data:Object):void
{
// Do stuff
}
####
TestBuyItem.as
[Test (order=1, async, timeout="60000")]
public function testBuyItem():void
{
Async.asyncHandler(this, callback, 20000, null, null);
DataManager.getInstance().purchaseItem("myitemid", callback);
}
private function callback(success:Boolean, data:Object
{
// This method gets called and success does equal true - however my test fails
Assert.assertTrue(success);
}
What am I doing wrong?
What type of method does the 'callback' need to be?
Is there an Async.waitForCallbackFunctionCall()
I am sure I am doing something wrong, I am just not sure what - thanks for any help you can offer.
--jason
