/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
- package org.osflash.signals
- {
- import asunit.asserts.*;
- public class AmbiguousRelationshipTest
- {
- private var target:Object;
-
- private var instance:Signal;
- [Before]
- public function setUp():void
- {
- target = {};
- instance = new Signal();
- }
- [After]
- public function tearDown():void
- {
- instance = null;
- }
-
- [Test(expects="flash.errors.IllegalOperationError")]
- public function add_then_addOnce_throws_error():void
- {
- instance.add(failIfCalled);
- instance.addOnce(failIfCalled);
- }
-
- [Test(expects="flash.errors.IllegalOperationError")]
- public function addOnce_then_add_should_throw_error():void
- {
- instance.addOnce(failIfCalled);
- instance.add(failIfCalled);
- }
-
- [Test]
- public function add_then_add_should_not_throw_error():void
- {
- instance.add(failIfCalled);
- instance.add(failIfCalled);
- assertEquals(1, instance.numListeners);
- }
-
- [Test]
- public function addOnce_then_addOnce_should_not_throw_error():void
- {
- instance.addOnce(failIfCalled);
- instance.addOnce(failIfCalled);
- assertEquals(1, instance.numListeners);
- }
-
- private function failIfCalled():void
- {
- fail("if this listener is called, something horrible is going on");
- }
-
- }
- }