### Question:
IconRemover { public void deleteIcons() { IconRecord record = myModel.selectedRecordProperty().get(); if(record != null) { myModel.getModel().getIconRecords().remove(record); myModel.getIconRegistry().removeIcon(record, this); } } IconRemover(IconModel model); void deleteIcons();  }### Answer:
@Test public void test() { EasyMockSupport support = new EasyMockSupport(); IconRecord icon = support.createMock(IconRecord.class); EasyMock.expect(icon.collectionNameProperty()).andReturn(new SimpleStringProperty("User")).anyTimes(); EasyMock.expect(icon.favoriteProperty()).andReturn(new SimpleBooleanProperty(false)).anyTimes(); EasyMock.expect(icon.getTags()).andReturn(FXCollections.observableArrayList()).anyTimes(); EasyMock.expect(icon.nameProperty()).andReturn(new SimpleStringProperty("testIcon")).anyTimes(); EasyMock.expect(icon.descriptionProperty()).andReturn(new SimpleStringProperty("A description")).anyTimes(); IconRegistry iconRegistry = createIconRegistry(support, icon); EasyMock.expect(Boolean.valueOf(iconRegistry.removeIcon(EasyMock.eq(icon), EasyMock.isA(IconRemover.class)))).andReturn(Boolean.TRUE); Toolbox toolbox = support.createMock(Toolbox.class); support.replayAll(); IconModel model = new IconModel(toolbox); model.setIconRegistry(iconRegistry); model.selectedRecordProperty().set(icon); assertEquals(1, model.getModel().getIconRecords().size()); assertEquals(icon, model.getModel().getIconRecords().get(0)); IconRemover remover = new IconRemover(model); remover.deleteIcons(); assertTrue(model.getModel().getIconRecords().isEmpty()); support.verifyAll(); }
@Test public void testRemoveNothingSelected() { EasyMockSupport support = new EasyMockSupport(); IconRegistry iconRegistry = createIconRegistry(support); Toolbox toolbox = support.createMock(Toolbox.class); support.replayAll(); IconModel model = new IconModel(toolbox); model.setIconRegistry(iconRegistry); IconRemover remover = new IconRemover(model); remover.deleteIcons(); support.verifyAll(); }