PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/org/osflash/signals/SignalDispatchNoArgsTest.as

http://github.com/robertpenner/as3-signals
ActionScript | 55 lines | 46 code | 7 blank | 2 comment | 0 complexity | 40d314551a272fd740e953951c4ac572 MD5 | raw file
 1package org.osflash.signals
 2{
 3	import asunit.asserts.*;
 4	import asunit.framework.IAsync;
 5
 6	public class SignalDispatchNoArgsTest
 7	{	
 8	    [Inject]
 9	    public var async:IAsync;
10	    
11		public var signal:ISignal;
12
13		[Before]
14		public function setUp():void
15		{
16			signal = new Signal();
17		}
18
19		[After]
20		public function tearDown():void
21		{
22			signal.removeAll();
23			signal = null;
24		}
25		//////
26		[Test]
27		public function dispatch_no_args_should_call_listener_with_no_args():void
28		{
29			signal.add( async.add(onCompleted, 10) );
30			signal.dispatch();
31		}
32		
33		private function onCompleted():void
34		{
35			assertEquals(0, arguments.length);
36		}
37		//////
38		[Test]
39		public function addOnce_in_handler_and_dispatch_should_call_new_listener():void
40		{
41			signal.addOnce( async.add(addOnceInHandler, 10) );
42			signal.dispatch();
43		}
44		
45		protected function addOnceInHandler():void
46		{
47			signal.addOnce( async.add(secondAddOnceListener, 10) );
48			signal.dispatch();
49		}
50		
51		protected function secondAddOnceListener():void
52		{
53		}
54	}
55}