PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/org/osflash/signals/MonoSignalDispatchNoArgsTest.as

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