### Question:
MultiItemLayoutSelector implements ItemLayoutSelector { @Override public int getItemViewType(Object item, int position) { ViewTypeSelectionContext<Object> context = new ViewTypeSelectionContext<Object>(getViewTypeCount(), item, position); int selectedViewType = userSelectViewType(context); checkViewType(selectedViewType); return selectedViewType; } MultiItemLayoutSelector(List<Integer> itemLayoutIds, ViewTypeSelectable viewTypeSelector); @Override int getViewTypeCount(); @Override int getItemViewType(Object item, int position); @Override int selectLayout(int viewType);  }### Answer:
@Test public void shouldReturnUserSelectedViewType() { int userSelectedViewType = RandomValues.nextInt(itemLayoutIds.size()); ViewTypeSelectable viewTypeSelector = withUserSelectedViewType(userSelectedViewType); MultiItemLayoutSelector layoutSelector = new MultiItemLayoutSelector(itemLayoutIds, viewTypeSelector); int actualViewType = layoutSelector.getItemViewType(anyItem(), anyPosition()); assertThat(actualViewType, equalTo(userSelectedViewType)); }
@Test public void shouldThrowExceptionGivenInvalidUserSelectedViewType() { thrownException.expect(RuntimeException.class); thrownException.expectMessage("invalid selected view type"); int invalidUserSelectedViewType = itemLayoutIds.size() + RandomValues.anyInteger(); ViewTypeSelectable viewTypeSelector = withUserSelectedViewType(invalidUserSelectedViewType); MultiItemLayoutSelector layoutSelector = new MultiItemLayoutSelector(itemLayoutIds, viewTypeSelector); layoutSelector.getItemViewType(anyItem(), anyPosition()); }