diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-05 19:49:59 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-05 19:49:59 +0200 |
commit | 53824198db2bade71c895c91caab14f338139fd2 (patch) | |
tree | 8f1f6f10c91bec59292e2a5980ea1346b12c6d79 /test/jrummikub | |
parent | 44ee94041a1f042408033663df992803a2970872 (diff) | |
download | JRummikub-53824198db2bade71c895c91caab14f338139fd2.tar JRummikub-53824198db2bade71c895c91caab14f338139fd2.zip |
Added tests for Connection
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@150 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub')
-rw-r--r-- | test/jrummikub/util/Event1Test.java | 25 | ||||
-rw-r--r-- | test/jrummikub/util/Event2Test.java | 29 | ||||
-rw-r--r-- | test/jrummikub/util/EventTest.java | 25 |
3 files changed, 79 insertions, 0 deletions
diff --git a/test/jrummikub/util/Event1Test.java b/test/jrummikub/util/Event1Test.java index 3f8839d..c3f388e 100644 --- a/test/jrummikub/util/Event1Test.java +++ b/test/jrummikub/util/Event1Test.java @@ -80,4 +80,29 @@ public class Event1Test { testEvent.emit(10); assertEquals(fired, 10); } + + @Test + public void removeListenerByConnection() { + fired = 0; + Event1<Integer> testEvent = new Event1<Integer>(); + testEvent.add(new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fired += n; + + } + }); + IListener1<Integer> rem = new IListener1<Integer>() { + + @Override + public void handle(Integer n) { + fail(); + } + }; + Connection connection = testEvent.add(rem); + connection.remove(); + testEvent.emit(10); + assertEquals(fired, 10); + } } diff --git a/test/jrummikub/util/Event2Test.java b/test/jrummikub/util/Event2Test.java index 6d1958e..c258ddf 100644 --- a/test/jrummikub/util/Event2Test.java +++ b/test/jrummikub/util/Event2Test.java @@ -93,4 +93,33 @@ public class Event2Test { assertEquals(fired, 10); assertEquals(fired2, 20); } + + @Test + public void removeListenerByConnection() { + fired = 0; + fired2 = 0; + Event2<Integer, Integer> testEvent = new Event2<Integer, Integer>(); + testEvent.add(new IListener2<Integer, Integer>() { + + @Override + public void handle(Integer n, Integer m) { + fired += n; + fired2 += m; + } + }); + IListener2<Integer, Integer> rem = new IListener2<Integer, Integer>() { + + @Override + public void handle(Integer n, Integer m) { + fail(); + } + }; + assertEquals(fired, 0); + assertEquals(fired2, 0); + Connection connection = testEvent.add(rem); + connection.remove(); + testEvent.emit(10, 20); + assertEquals(fired, 10); + assertEquals(fired2, 20); + } } diff --git a/test/jrummikub/util/EventTest.java b/test/jrummikub/util/EventTest.java index 15bd632..f8c505c 100644 --- a/test/jrummikub/util/EventTest.java +++ b/test/jrummikub/util/EventTest.java @@ -79,5 +79,30 @@ public class EventTest { testEvent.emit(); assertTrue(fired); } + + @Test + public void removeListenerByConnection() { + fired = false; + Event testEvent = new Event(); + testEvent.add(new IListener() { + + @Override + public void handle() { + fired = true; + + } + }); + IListener rem = new IListener() { + + @Override + public void handle() { + fail(); + } + }; + Connection connection = testEvent.add(rem); + connection.remove(); + testEvent.emit(); + assertTrue(fired); + } } |