@Test public void can_get_buttons() { DialogBox dialogBox = new DialogBox(evaluator, id); List<Button> buttons = new ArrayList<Button>(); buttons.add(null); buttons.add(null); buttons.add(null); when(evaluator.buttons(dialogBox)).thenReturn(buttons); assertThat(dialogBox.buttons().size(), is(3)); }
@Test public void test_dialogbox_message() { DialogBox dialogBox = new DialogBox(evaluator, id); when(evaluator.message(dialogBox)).thenReturn("message"); assertThat(dialogBox.message(), is("message")); }
@Test public void test_toString() { DialogBox dialogBox = new DialogBox(evaluator, id); when(evaluator.isVisible(any(Component.class))).thenReturn(true); when(evaluator.isEnabled(any(Component.class))).thenReturn(true); when(evaluator.title(dialogBox)).thenReturn("title"); when(evaluator.message(dialogBox)).thenReturn("message"); assertThat(dialogBox.toString(), is("class org.testatoo.core.component.DialogBox with state : enabled:true, visible:true, title:title, message:message")); } }
@Test public void test_component_type() { evaluator = mock(Evaluator.class); when(evaluator.existComponent(id)).thenReturn(true); when(evaluator.componentType(id)).thenReturn(Radio); try { new DialogBox(evaluator, id); fail(); } catch (ComponentException e) { assertThat(e.getMessage(), is("The component with id=" + id + " is not a DialogBox but a Radio")); } }