/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

  1. package org.osflash.signals
  2. {
  3. import asunit.asserts.*;
  4. public class AmbiguousRelationshipTest
  5. {
  6. private var target:Object;
  7. private var instance:Signal;
  8. [Before]
  9. public function setUp():void
  10. {
  11. target = {};
  12. instance = new Signal();
  13. }
  14. [After]
  15. public function tearDown():void
  16. {
  17. instance = null;
  18. }
  19. [Test(expects="flash.errors.IllegalOperationError")]
  20. public function add_then_addOnce_throws_error():void
  21. {
  22. instance.add(failIfCalled);
  23. instance.addOnce(failIfCalled);
  24. }
  25. [Test(expects="flash.errors.IllegalOperationError")]
  26. public function addOnce_then_add_should_throw_error():void
  27. {
  28. instance.addOnce(failIfCalled);
  29. instance.add(failIfCalled);
  30. }
  31. [Test]
  32. public function add_then_add_should_not_throw_error():void
  33. {
  34. instance.add(failIfCalled);
  35. instance.add(failIfCalled);
  36. assertEquals(1, instance.numListeners);
  37. }
  38. [Test]
  39. public function addOnce_then_addOnce_should_not_throw_error():void
  40. {
  41. instance.addOnce(failIfCalled);
  42. instance.addOnce(failIfCalled);
  43. assertEquals(1, instance.numListeners);
  44. }
  45. private function failIfCalled():void
  46. {
  47. fail("if this listener is called, something horrible is going on");
  48. }
  49. }
  50. }