PageRenderTime 196ms CodeModel.GetById 191ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/org/osflash/signals/AmbiguousRelationshipTest.as

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