Quantcast
Channel: Adobe Community : Popular Discussions - FlexUnit
Viewing all articles
Browse latest Browse all 25673

Async testing question

$
0
0

Hello,

 

I would like to now how to proceed to test a delegate class that is taking an IResponder as method parameter.

 

For exemple :

 

LoginDelegate.as (simplified version) :

 

publicfunction login( responder : IResponder, username : String, password : String ) : void

 

 

{

var s : SomeService = new SomeService();

 

s.addEventListener( ResultEvent.RESULT, responder.result );

s.addEventListener( FaultEvent.FAULT, responder.fault );

 

 

 

s.login( username, password );

 

 

}

 

As you can see, the delegate communicate with some backend service and then calls the provided responder methods.

 

I tried to use Async.asyncResponder without luck:

 

[Before(async)]

publicfunction runBeforeAsyncTest():void

{

var d : LoginDelegate = new LoginDelegate();

var responder : Responder = new Responder(result,fault);

 

Async.asyncResponder(this, responder, 5000);

 

d.login(responder, "someuser", "somepass");

 

}

 

publicfunction result(data:Object):void

{

trace("result");

}

publicfunction fault(info:Object):void

{

trace("fault");

}

 

[Test]

publicfunction testLoginFail():void

{

trace("testLoginFail")

Assert.assertEquals("5", 5);

}

 

It goes in result method, then It fails with :

testLoginFail Error: Timeout Occurred before expected event

 

Can someone please tell me how to test my delegate properly

 

Thank you in advance


Viewing all articles
Browse latest Browse all 25673

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>