@Test public void radio_usage_through_language() { when(evaluator.componentType(id)).thenReturn(Radio); Radio radio = new Radio(evaluator, id); when(evaluator.label(radio)).thenReturn("myLabel"); when(evaluator.isChecked(radio)).thenReturn(false, true); assertThat(radio, is(not(checked()))); check(radio); assertThat(radio, is(checked())); and(it(), has(label("myLabel"))); assertThat(radio, has(label("myLabel"))); verify(evaluator, times(1)).check(radio); verify(evaluator, times(2)).isChecked(radio); }
@Test public void checkbox_usage_through_language() { when(evaluator.componentType(id)).thenReturn(CheckBox); CheckBox checkBox = new CheckBox(evaluator, id); when(evaluator.isChecked(checkBox)).thenReturn(false, true, false); when(evaluator.label(checkBox)).thenReturn("myLabel"); assertThat(checkBox, is(not(checked()))); check(checkBox); assertThat(checkBox, is(checked())); unCheck(checkBox); assertThat(checkBox, is(not(checked()))); assertThat(checkBox, has(label("myLabel"))); verify(evaluator, times(1)).check(checkBox); verify(evaluator, times(1)).unCheck(checkBox); verify(evaluator, times(3)).isChecked(checkBox); }