### Question:
Context implements IContext<TEntity> { public void OnEntityDestroyed(ContextEntityChanged listener) { if (OnEntityDestroyed != null) { OnEntityDestroyed = EntitasCollections.createSet(ContextEntityChanged.class); } OnEntityDestroyed.add(listener); } Context(int totalComponents, int startCreationIndex, ContextInfo contexInfo,
                   EntityBaseFactory<TEntity> factoryMethod, Function<TEntity, IAERC> aercFactory); @Override TEntity createEntity(); @Override void destroyAllEntities(); @Override boolean hasEntity(TEntity entity); @Override TEntity[] getEntities(); @Override int getTotalComponents(); @Override Group<TEntity> getGroup(IMatcher matcher); @Override void addEntityIndex(IEntityIndex entityIndex); @Override IEntityIndex getEntityIndex(String name); @Override void resetCreationIndex(); @Override void clearComponentPool(int index); @Override void clearComponentPools(); @Override void reset(); void updateGroupsComponentAddedOrRemoved(TEntity entity, int index, IComponent component, List<Group<TEntity>>[] groupsForIndex); @Override Stack<IComponent>[] getComponentPools(); @Override ContextInfo getContextInfo(); @Override int getCount(); @Override int getReusableEntitiesCount(); @Override int getRetainedEntitiesCount(); IEntity[] getEntities(IMatcher matcher); @Override Collector createCollector(IMatcher matcher); @Override Collector createCollector(IMatcher matcher, GroupEvent groupEvent); Collector<TEntity> createCollector(Context context, TriggerOnEvent<TEntity>[] triggers); void clearEventsListener(); void OnEntityCreated(ContextEntityChanged listener); void OnEntityWillBeDestroyed(ContextEntityChanged listener); void OnEntityDestroyed(ContextEntityChanged listener); void OnGroupCreated(ContextGroupChanged listener); void notifyEntityCreated(IEntity entity); void notifyEntityWillBeDestroyed(IEntity entity); void notifyEntityDestroyed(IEntity entity); void notifyGroupCreated(IGroup group); @Override String toString(); public int _totalComponents; public Class<TEntity> entityType; public Set<ContextEntityChanged> OnEntityCreated; public Set<ContextEntityChanged> OnEntityWillBeDestroyed; public Set<ContextEntityChanged> OnEntityDestroyed; public Set<ContextGroupChanged> OnGroupCreated; }### Answer:
@Test public void OnEntityDestroyedTest() { context.OnEntityWillBeDestroyed((IContext pool, IEntity e) -> assertTrue(e.isEnabled())); context.OnEntityDestroyed((pool, e) -> assertFalse(e.isEnabled())); context.destroyAllEntities(); assertEquals(0, context.getCount()); }