### Question:
InMemoryMessageVerifier { public static boolean eventPublished(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher, final Event event) { return publishedEvents(inMemoryMessagePublisher, event.getClass()).contains(event); }  static boolean messageTypeSent(final InMemoryMessageSender<TypedMessage> inMemoryMessageSender,
            final String messageType); static boolean eventTypePublished(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher,
            final Class<? extends Event> eventClass); static boolean eventPublished(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher,
            final Event event); @SafeVarargs static List<Event> publishedEvents(final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher,
            final Class<? extends Event>... eventClasses);  }### Answer:
@Test public void shouldReturnTrueWhenEventPublished_onEventPublished() { final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher = mock(InMemoryMessagePublisher.class); final List<TypedMessage> mockPublishedMessages = new ArrayList<>(); final StubEvent publishedEvent = new StubEvent(); publishedEvent.setEventField(randomString()); addSerializedEventMessage(mockPublishedMessages, publishedEvent); when(inMemoryMessagePublisher.getPublishedMessages()).thenReturn(mockPublishedMessages); final boolean eventPublished = InMemoryMessageVerifier.eventPublished(inMemoryMessagePublisher, publishedEvent); assertTrue(eventPublished); }
@Test public void shouldReturnFalseWhenEventNotPublished_onEventPublished() { final InMemoryMessagePublisher<TypedMessage> inMemoryMessagePublisher = mock(InMemoryMessagePublisher.class); final List<TypedMessage> mockPublishedMessages = new ArrayList<>(); when(inMemoryMessagePublisher.getPublishedMessages()).thenReturn(mockPublishedMessages); final StubEvent expectedEvent = new StubEvent(); expectedEvent.setEventField(randomString()); final boolean eventPublished = InMemoryMessageVerifier.eventPublished(inMemoryMessagePublisher, expectedEvent); assertFalse(eventPublished); }