PageRenderTime 73ms CodeModel.GetById 57ms app.highlight 9ms RepoModel.GetById 4ms app.codeStats 0ms

/tests/org/osflash/signals/natives/AmbiguousRelationshipInNativeSignalTest.as

http://github.com/robertpenner/as3-signals
ActionScript | 63 lines | 52 code | 11 blank | 0 comment | 0 complexity | 36db2e0de102ccf7ab9256fdf36403b6 MD5 | raw file
 1package org.osflash.signals.natives
 2{
 3	import asunit.asserts.*;
 4
 5	import flash.display.Sprite;
 6	import flash.events.Event;
 7
 8	public class AmbiguousRelationshipInNativeSignalTest
 9	{
10		private var target:Sprite;
11		
12		private var instance:NativeSignal;
13
14		[Before]
15		public function setUp():void
16		{
17			target = new Sprite();
18			instance = new NativeSignal(target, Event.CHANGE);
19		}
20
21		[After]
22		public function tearDown():void
23		{
24			instance = null;
25		}
26		
27		[Test(expects="flash.errors.IllegalOperationError")]
28		public function add_then_addOnce_throws_error():void
29		{
30			instance.add(failIfCalled);
31			instance.addOnce(failIfCalled);
32		}
33		
34		[Test(expects="flash.errors.IllegalOperationError")]
35		public function addOnce_then_add_should_throw_error():void
36		{
37			instance.addOnce(failIfCalled);
38			instance.add(failIfCalled);
39		}
40		
41		[Test]
42		public function add_then_add_should_not_throw_error():void
43		{
44			instance.add(failIfCalled);
45			instance.add(failIfCalled);
46			assertEquals(1, instance.numListeners);
47		}
48		
49		[Test]
50		public function addOnce_then_addOnce_should_not_throw_error():void
51		{
52			instance.addOnce(failIfCalled);
53			instance.addOnce(failIfCalled);
54			assertEquals(1, instance.numListeners);
55		}
56		
57		private function failIfCalled(event:Event):void
58		{
59			fail("if this listener is called, something horrible is going on");
60		}
61		
62	}
63}