Code example for Spinner

Methods: getSelectedItem

0
		assertThat((String) spinner.getSelectedItem()).isNotEqualTo("foo");
	} 
	 
	@Test 
	public void getSelectedItemShouldReturnNull_NoAdapterSet(){ 
        assertThat(spinner.getSelectedItem()).isNull();
	} 
	 
	@Test (expected = IndexOutOfBoundsException.class)	 
	public void getSelectedItemShouldThrowException_EmptyArray(){ 
		spinner.setAdapter(new MyArrayAdapter(context, new String[]{}));
		spinner.getSelectedItem();		
	} 
	 
	@Test 
	public void setSelectionWithAnimatedTransition() {		 
		spinner.setAdapter(arrayAdapter);
		spinner.setSelection(0, true);
 
        assertThat((String) spinner.getSelectedItem()).isEqualTo("foo");
        assertThat((String) spinner.getSelectedItem()).isNotEqualTo("bar");