summaryrefslogtreecommitdiff
path: root/same/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'same/src/test')
-rw-r--r--same/src/test/java/com/orbekk/same/VariableFactoryTest.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/same/src/test/java/com/orbekk/same/VariableFactoryTest.java b/same/src/test/java/com/orbekk/same/VariableFactoryTest.java
index 7d20fa7..a6efa4b 100644
--- a/same/src/test/java/com/orbekk/same/VariableFactoryTest.java
+++ b/same/src/test/java/com/orbekk/same/VariableFactoryTest.java
@@ -59,4 +59,22 @@ public class VariableFactoryTest {
string.set("NewValue");
verify(client).set("X", "\"NewValue\"", 0);
}
+
+ @Test
+ public void addsListener() throws Exception {
+ Variable<String> v = vf.create("X", stringType);
+ verify(client).addStateListener((StateChangedListener)v);
+ }
+
+ @Test
+ public void listenerNotifies() throws Exception {
+ @SuppressWarnings("unchecked")
+ Variable.OnChangeListener<Integer> listener =
+ mock(Variable.OnChangeListener.class);
+ Variable<Integer> v = vf.create("z", intType);
+ v.setOnChangeListener(listener);
+ ((StateChangedListener) v).stateChanged(
+ new State.Component("z", 1, "abc"));
+ verify(listener).valueChanged(v);
+ }
}