Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2008 Ovea <dev@testatoo.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package org.testatoo.core.component;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.*;
import static org.testatoo.core.ComponentType.Radio;
import static org.testatoo.core.ComponentType.TextField;
public class TextFieldTest {
    private Evaluator evaluator;
    private String id = "myId";
    @Before
    public void setUp() {
         = mock(Evaluator.class);
        when(.existComponent()).thenReturn(true);
        when(.isVisible(any(Field.class))).thenReturn(true);
        when(.isEnabled(any(Field.class))).thenReturn(true);
    }
    @Test
    public void test_component_type() {
         = mock(Evaluator.class);
        when(.existComponent()).thenReturn(true);
        try {
            new TextField();
            fail();
        } catch (ComponentException e) {
            assertThat(e.getMessage(), is("The component with id=" +  + " is not a TextField but a Radio"));
        }
    }
    @Test
        when(.value(any(TextField.class))).thenReturn("");
        when(.label(any(TextField.class))).thenReturn("");
        when(.maxLength(any(TextField.class))).thenReturn(10);
        TextField textField = new TextField();
        assertThat(textField.maxLength(), is(10));
    }
    @Test
    public void test_toString() {
        when(.value(any(TextField.class))).thenReturn("myValue");
        when(.label(any(TextField.class))).thenReturn("label");
        when(.maxLength(any(TextField.class))).thenReturn(10);
        TextField textField = new TextField();
        assertThat(textField.toString(), is("class org.testatoo.core.component.TextField with state : enabled:true, visible:true, value:myValue, label:label, maxLength:10"));
    }
New to GrepCode? Check out our FAQ X