    @Test
    public void testAttachView() {

        when(chatServiceMock.getMessages()).thenReturn(Observable.just(testMessages));
        when(chatServiceMock.addMessage(chatMessageCaptor.capture())).thenReturn(Observable.just(testMessages.get(0)));
        when(chatPresenterViewMock.getNewMessage()).thenReturn(Observable.just(testMessageString));

        chatPresenter.attachView(chatPresenterViewMock);

        verify(chatPresenterViewMock).setListOfMessage(listChatMessageCaptor.capture());
        for (int i = 0; i < testMessages.size(); i++) {
            assertEquals(listChatMessageCaptor.getValue().get(i).toString(), testMessages.get(i).toString());
        }

        ChatMessage messageSend = chatMessageCaptor.getValue();
        assertEquals(messageSend.pseudo(), "test");
        assertEquals(messageSend.message(), testMessageString);
        assertNotNull(messageSend.date());

        chatPresenter.detachView();
        when(chatPresenterViewSecondMock.getNewMessage()).thenReturn(Observable.just(testMessageString));
        chatPresenter.attachView(chatPresenterViewSecondMock);

        verify(chatPresenterViewSecondMock).setListOfMessage(listChatMessageCaptor.capture());
        for (int i = 0; i < testMessages.size(); i++) {
            assertEquals(listChatMessageCaptor.getValue().get(i).toString(), testMessages.get(i).toString());
        }

        chatPresenter.destroy();
    }